Selecting and formatting pictures

L

Lee

I have a macro in Excel that opens files and copies and pastes pictures of
various pages into Word. There is a single picture on a page. After the
pictures are pasted in then I need to resize and center the pictures on each
page (the same size for each picture). I'm struggling with a piece of code:

Sub aaa_format()
Dim count As Integer
count = 1
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")
BOEHeight
Loop
End Sub

Sub BOEHeight()
Selection.InlineShapes(1).Height = 450.7
Selection.InlineShapes(1).Width = 581.75
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.MoveDown Unit:=wdLine, count:=1
End Sub

It does not move down correctly. After selecting the first picture, how can
I code this to change the parameters for the selected picture, then move to
the next picture on the next page? It currently will do a few pages but
randomly stops when it does not select a picture.

Is there a way to select all of the pictures and resize all of them at one
time?

Thanks for any help.
 
J

Jean-Guy Marcil

Lee was telling us:
Lee nous racontait que :
I have a macro in Excel that opens files and copies and pastes
pictures of various pages into Word. There is a single picture on a
page. After the pictures are pasted in then I need to resize and
center the pictures on each page (the same size for each picture).
I'm struggling with a piece of code:

Sub aaa_format()
Dim count As Integer
count = 1
ActiveWindow.ActivePane.VerticalPercentScrolled = 0
Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")
BOEHeight
Loop
End Sub

Sub BOEHeight()
Selection.InlineShapes(1).Height = 450.7
Selection.InlineShapes(1).Width = 581.75
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.MoveDown Unit:=wdLine, count:=1
End Sub

It does not move down correctly. After selecting the first picture,
how can I code this to change the parameters for the selected
picture, then move to the next picture on the next page? It
currently will do a few pages but randomly stops when it does not
select a picture.

Is there a way to select all of the pictures and resize all of them
at one time?

Thanks for any help.

Your two subs could be replaced by:

'_______________________________________
Dim myPix As InlineShape

For Each myPix In ActiveDocument.InlineShapes
With myPix
.Height = 450.7
.Width = 581.75
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
Next
'_______________________________________

Avoid using the Selection object... very unstable, as you have observed.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
L

Lee

Thank You!!
--
Lee Kirts


Jean-Guy Marcil said:
Lee was telling us:
Lee nous racontait que :


Your two subs could be replaced by:

'_______________________________________
Dim myPix As InlineShape

For Each myPix In ActiveDocument.InlineShapes
With myPix
.Height = 450.7
.Width = 581.75
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
Next
'_______________________________________

Avoid using the Selection object... very unstable, as you have observed.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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