Hi macropod,
I took the code for Filethere from following site:
Code:
http://word.tips.net/T000819_Determining_if_a_File_Exists.html
It is functional. I just merged it with the doc name part to make it work for any document.
This part gets doc name:
Code:
'get my document name without .doc/.docx and other extensions
Dim doc As String
If InStrRev(ActiveDocument.Name, ".") <> 0 Then
doc = Left(ActiveDocument.Name, InStrRev(ActiveDocument.Name, ".") - 1)
Else
doc = ActiveDocument
End If
This part checks if same name image exists
Code:
'check if my image exists and matches my document name
'if image found then add new page and copy image
If FileThere(ActiveDocument.Path & "\images\" & doc & ".jpg") Then '>>>>> relates to the function written above
Selection.InsertNewPage
Selection.InlineShapes.AddPicture FileName:= _
ActiveDocument.Path & "\images\" & doc & ".jpg", _
LinkToFile:=False, SaveWithDocument:=True
The issue is that the loop isn't functional