Office Macros - Inserting Pics & File browser

Soldato
Joined
18 Oct 2002
Posts
4,205
Location
West Lancashire
I have the following code to help me insert pictures into a word table/schedule at work. Colleagues will often go on site and take 100+ photos that have to be presented in a standard office format and allow for commenting.

I've cut out the crap that moves from one cell to the next to make it simpler to see the code that's doing the work. I've also removed that code that adds the filenames.

Code:
Sub Insert_Pictures()
Dim sNextFile As String
Dim sPath As String
Dim mta99 As String

sPath = InputBox("Enter the full path")

sNextFile = Dir$(sPath)
While sNextFile <> " "
    mta99 = sPath & sNextFile
    Selection.InlineShapes.AddPicture FileName:=mta99, _
        LinkToFile:=False, SaveWithDocument:=True
    Selection.TypeParagraph
    sNextFile = Dir$
Wend

End Sub

So at the moment I have to copy and paste the path from explorer but I would love to have a file browser to make things much more elegant. The code also crashes at the end when it runs out of files, this isn't a problem but again its messy.

Any suggestions? :)
 
Back
Top Bottom