I am currently trying to write a macro which will open an embedded pdf file in from excel, open it in acrobat reader, automatically save a copy of it into a predesignated folder, and return to excel to repeat the process. I can't seem to retain control over acrobat after I open the embedded file. Does anyone have any ideas? Code is posted below.
Sub ExcelCopySaveExistingPdf()
Dim MyDir As String
Dim strPath As String
Dim PDApp As AcroApp
Dim PDDoc As AcroPDDoc
MyDir = ActiveWorkbook.Path
strPath = MyDir & "\Sample Touchpoint"
On Error Resume Next
ActiveSheet.Shapes("Object 23").Select
Set PDApp = GetObject("Object 23", "Acrobat.AcroApp")
Selection.Verb Verb:=xlOpen
'Set PDApp = Selection
If PDApp Is Nothing Then
' PowerPoint is not running, create new instance
Set PDApp = CreateObject("Acrobat.AcroApp")
Set PDDoc = PDApp.GetActiveDoc
End If
On Error GoTo 0
'GoTo Line25
On Error Resume Next
If PDApp.Show = True Then
' There is at least one open Acro-doc
' Use existing Acro-doc
Set PDDoc = AcroApp.ActiveDoc
Else
' There are no Docs
' Create new one
Set PDDoc = AcroPDDoc.Add
End If
On Error GoTo 0
Line25:
With PDDoc
'.Save (strPath & "\TESTPRES.pdf")
'.Save
.Close
End With
PDApp.Exit
' Clean up
Set PDDoc = Nothing
Set PDApp = Nothing
End Sub
Bookmarks