Ken said:
Hi,
I have a dumb question that I couldn't find in the book
and website. How can I insert 5 images that are all jpg
files in a word document using the vba code. thanks!
ken
Hi, Ken,
Here's some simple code that just sticks the pictures in next to each other
at the current cursor position, using whatever sizes they happen to be. If
you need to resize, reposition, caption, or otherwise adjust each picture,
the code can get more complicated.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://www.mvps.org/word
Sub FiveJPGs()
Dim JPGFileName(5) As String
Dim Counter As Integer
'JPGFileName(0) = ""
JPGFileName(1) = "c:\graphics\firework.jpg"
JPGFileName(2) = "c:\graphics\stones.jpg"
JPGFileName(3) = "c:\graphics\nightwatch.jpg"
JPGFileName(4) = "c:\graphics\horsehead.jpg"
JPGFileName(5) = "c:\graphics\f18cloud.jpg"
For Counter = 1 To 5
Selection.Collapse direction:=wdCollapseEnd
ActiveDocument.InlineShapes.AddPicture _
FileName:=JPGFileName(Counter), _
linktofile:=False, savewithdocument:=True, _
Range:=Selection.Range
' go from left side of picture to right side
Selection.Move unit:=wdCharacter, Count:=1
Next Counter
End Sub