I am trying to use VBA to open a PDF in an existing Adobe Acrobat window.
Currently, however, my code is opening the pdf in a separate Adobe window each time it is run.
End goal: VBA opens a PDF in an existing Adobe acrobat window in the form of a new PDF tab.
Here is my code:
Sub openPDF(sPath As String)
Dim primaryDoc As Object, PrimaryAVDoc As Object, appAdobe As Object ' Open Adobe instance
Dim zPath As String
Dim adobeDoc As Variant, PDFPageView As Variant
Set appAdobe = CreateObject("AcroExch.App")
' Create Adobe PDF object
Set primaryDoc = CreateObject("AcroExch.PDDoc")
Set PrimaryAVDoc = CreateObject("AcroExch.AVDoc")
If PrimaryAVDoc.Open(sPath, "") = True Then
PrimaryAVDoc.BringToFront
Call PrimaryAVDoc.Maximize(True)
Set PDFPageView = PrimaryAVDoc.GetAVPageView()
' Zoom (optional)
' Call PDFPageView.ZoomTo(2, 50)
End If
Set primaryDoc = Nothing
Set PrimaryAVDoc = Nothing
Set appAdobe = Nothing
End Sub