changing without ending

G

Greg

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
 
C

Cindy M -WordMVP-

Hi Greg,
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?
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
:)
 
G

Greg

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
 
G

Graham Mayor

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.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

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,
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
 
C

Cindy M -WordMVP-

<eqZM#[email protected]>
<[email protected]>
Newsgroups: microsoft.public.word.vba.general
NNTP-Posting-Host: 20.80.3.213.cust.bluewin.ch 213.3.80.20
Lines: 1
Path: number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!msrtrans!TK2MSFTFEEDS01.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTNGP02.phx.gbl
Xref: number1.nntp.dca.giganews.com microsoft.public.word.vba.general:86146

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,
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
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 :)
 
J

Jonathan West

Greg said:
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


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.


--
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
 
A

Anet

thank you very much !

"vbModeless" is exactly what I need.

Unfortunately, WindowSelectionChange is too complicated for me so far.

Regards
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top