Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

changing without ending

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 20 May 2006 07:00 GMT
I can write macro which works in this way:
1)    choose an image
2)    change size and position
3)    close UserForm

but more useful will be macro working in this way:
1)    run macro
2)    open UseForm
3)    choose an image
4)    change size and position
5)    choose next image
6)    ....

Is it possible?

Greg
Cindy M  -WordMVP- - 20 May 2006 19:50 GMT
Hi Greg,

> I can write macro which works in this way:
> 1) choose an image
[quoted text clipped - 10 lines]
>  
> Is it possible?

It ought to be. Hard to say much more without more details,
starting with the version of Word involved :-) The other
key points:
   - what problem are you currently having, that you
aren't able to do this?

   - it's a bit unclear whether "change size and position"
is supposed to be done by user input, by the macro, by the
user manipulating the image directly

   - may we assume the images are Shapes?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
Greg - 21 May 2006 08:42 GMT
Thank you Cindy.

At now more details :)

- I use Word 2000
- I'm currently having only one but big problem: how to start :)
- "change size" should be done in this way that user set new size (for
example: 800px x 600px)
- exactly, the images are Shapes

Greg
Graham Mayor - 21 May 2006 09:58 GMT
Is there any reason why this application - which appears to be concerned
with displaying images - needs to be done in Word at all, when there are
lots of free applications around that handle graphics better? One such is
Google Picasa 2, which is worth downloading just for its ability to simply
straighten images. This will output images in 800x600 format, if that is
what you want to do.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> Thank you Cindy.
>
[quoted text clipped - 7 lines]
>
> Greg
Greg - 21 May 2006 12:36 GMT
Ok, I agree with you but "changing size" is only example.
I want to find out an algorithm how to do that user runs macro,
UserForm is opened and user can choose object (image, Textbox e.t.) to
edit it.
So far, I know how to write a macro using in this way:
1) user choose an object
2) user run macro with userform
3) user set size and/or position
4) user has to close UserForm
5) if user want to edit next object, he will have to run macro again

Greg
Cindy M  -WordMVP- - 22 May 2006 09:59 GMT
Hi Greg,

> Ok, I agree with you but "changing size" is only example.
> I want to find out an algorithm how to do that user runs macro,
[quoted text clipped - 6 lines]
> 4) user has to close UserForm
> 5) if user want to edit next object, he will have to run macro again

OK... Would it help you to build a list of objects in the document, to
present in the form? The user can select from the list, make the
changes, click OK, and you do the formatting.

All Shapes have a NAME property. Word will assign it when the shape is
inserted/created, but using VBA the name can be changed. So, roughly:

   Dim shp as Word.Shape

   For each shp in ActiveDocument.Shapes
       frm.ListBox.AddItem shp.Name
   Next

> - I use Word 2000
> - I'm currently having only one but big problem: how to start :)
> - "change size" should be done in this way that user set new size (for
> example: 800px x 600px)
> - exactly, the images are Shapes

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
Jonathan West - 22 May 2006 13:08 GMT
> Thank you Cindy.
>
[quoted text clipped - 5 lines]
> example: 800px x 600px)
> - exactly, the images are Shapes

OK, you can get as sophisticated as you want over this. But basically there
are three parts to the issue.

1. Letting the UserForm remain open while you select a new Shape
2. Loading the properties of the current Shape into the UserForm.
3. Applying any changes you make in the Userform to the current shape.

#1 is relatively easy. You can Show the userform using the vbModeless
parameter, so that your UserForm can remain displayed while you can continue
to select and edit items within the document window.

#2 is where you can choose whether to be sophisticated or not. The simple
way is to have a command button "Get current shape" which loads up the
settings for the currently selected shape and displays them. The
sophisticated way is to use the WindowSelectionChange event of Word's
Application object (see here for how to do this "Writing application event
procedures" http://www.word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm),
check whether the new selection is a Shape and load the userForm
accordingly.

Whichever way you handle #2, when the time comes to apply changes, you
should by now know which shape you are about to change, so you need an
"Apply changes" button which takes the changes you have made to settings in
the UserForm and apply them to the current shape.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Anet - 22 May 2006 15:49 GMT
thank you very much !

"vbModeless" is exactly what I need.

Unfortunately, WindowSelectionChange is too complicated for me so far.

Regards
Greg
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.