Insert an image into a word 2007 document

S

spnz

Hi there,

Does anyone have an example piece of code that inserts a .bmp file into a
word document from a selected folder location?


Any help would be really helpful.


Thanks in advance!
 
Z

Zkonker

spnz said:
Hi there,

Does anyone have an example piece of code that inserts a .bmp file into a
word document from a selected folder location?

I don't normally offer too much advice here, as the MVP's examples are
much more professional, but since I don't see a reply so far...


Sub paste_pic_1()
'
'
Dim i As Integer

Application.FileSearch.LookIn = "C:\Your_sub_here"
Application.FileSearch.FileName = "*.bmp"
Application.FileSearch.Execute

For i = 1 To Application.FileSearch.FoundFiles.Count
Selection.InlineShapes.AddPicture
FileName:=Application.FileSearch.FoundFiles.Item(i)
ActiveDocument.InlineShapes(i).LockAspectRatio = msoTrue
ActiveDocument.InlineShapes(i).Height = 180#
ActiveDocument.InlineShapes(i).Width = 239.75
Selection.InsertBefore (Application.FileSearch.FoundFiles.Item(i))
Next i


End Sub
 
C

Cindy M.

Hi Zkonker,
For i = 1 To Application.FileSearch.
FileSearch has been removed from Office 2007 because the
"search" functionality is now considered to be an operation
of the OS (Vista).

You'd need to rework your example to use the old DIR
command to have it work in 2007.

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

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