Positioning of image and text box problem

R

roblit

I have developed a Word macro that loops through a multipage document (of
letters) placing various images from the clipboard into the letters and then
surrounding each image by a text box.
My problem is that when I run it using RUN the textbox and image go to the
TOP of the page.
Yet when run in single step mode with F8, the image and text box correctly
stay at the current position on the page.
I have tried DoEvents and Sleep but it does not help.
Here is a cutdown piece of my code. It seems to be the Selection.ShapeRange
line that causes the movement to the top of the page.
Selection.Paste 'paste images from clipboard
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.CreateTextbox
Selection.ShapeRange.IncrementLeft 2.8
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1, Name:=""
' goto next page

To test it, first paste a small image onto the clipboard then go part way
down the 2nd page of a document then run the macro
I am using Word2003 with SP3, on XP pro v2002 SP3
Many thanks for looking at this.
Roblit
 
J

Jean-Guy Marcil

roblit was telling us:
roblit nous racontait que :
I have developed a Word macro that loops through a multipage document
(of letters) placing various images from the clipboard into the
letters and then surrounding each image by a text box.
My problem is that when I run it using RUN the textbox and image go
to the TOP of the page.
Yet when run in single step mode with F8, the image and text box
correctly stay at the current position on the page.
I have tried DoEvents and Sleep but it does not help.
Here is a cutdown piece of my code. It seems to be the
Selection.ShapeRange line that causes the movement to the top of the
page. Selection.Paste 'paste images from clipboard
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.CreateTextbox
Selection.ShapeRange.IncrementLeft 2.8
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Count:=1,
Name:="" ' goto next page

To test it, first paste a small image onto the clipboard then go part
way down the 2nd page of a document then run the macro
I am using Word2003 with SP3, on XP pro v2002 SP3
Many thanks for looking at this.
Roblit

I could not observe your described results.

What do you mean, exactly, by " when I run it using RUN"?
 
R

roblit

Hi
Thanks for looking at this.
The image goes to the top of the page, if I select the macro name and click
RUN (or if I first click "Step Into" then hit F5 from the macro first line.)

NB I have tried this macro on both Word 2000 and Word 2007 - both are okay.
It is just Word 2003 that has the problem.
I need the image to stay put, at the current cursor position.
Best wishes
Roblit
 

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