View Full Version : [SOLVED] Excel VBA - Change the current page of an already open PDF

11-03-2015, 06:06 PM
I've got some code that works well for word documents but I can't seem to get it to work for PDF's. The code is for documents that are already open and all it needs to do is change the page of the specific document and then show it on the screen above all other windows. Note that multiple files are likely to be open so it needs to be smart enough to determine which pdf is the correct one.
The working code for word docs is:

IsOpen = IsFileOpen(CompletePath)
If IsOpen = True Then
Dim objWord As Object
Set objWord = GetObject(CompletePath)
Set objWordinstance = objWord.Application
objWordinstance.Selection.Goto What:=1, Which:=2, Name:=page
objWordinstance.Visible = True
AppActivate (NameOfFile)
GoTo Ending
End If

The code that I can't get working is:

IsOpen = IsFileOpen(FullPathway)
If IsOpen = True Then
MsgBox "File is already Open."
Dim objPDF As Acrobat.AcroApp 'should this be object?
Set objPDF = GetObject(FullPathway, Acrobat.AcroApp)
Set objPDFinstance = objPDF.Application
objPDFinstance.Selection.Goto What:=1, Which:=2, Name:=page
objPDFinstance.Visible = True
AppActivate (FullPathway)
GoTo Ending
End If

FullPathway is where the pdf document is stored on the computer.
Anyone able to help with this?

11-04-2015, 07:06 PM
I found out that it is extremely difficult to work with PDF's to do this task so I ended up changing my entire system to work with Internet Explorer to view the files. In the end I don't need help any more. Cheers.