Thread: [Solved] Batch Processing Loop Issue
View Single Post
 
Old 07-15-2014, 02:32 AM
chirayu's Avatar
chirayu chirayu is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Jul 2014
Location: India
Posts: 4
chirayu is on a distinguished road
Default

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
Reply With Quote