- May 31, 2015
This is part of my code where I import a PDF file to embed into excel. It works. This opens a file dialog where I choose the PDF. If I don't choose a file and cancel, it still returns an Object, so I can't test to see if the user actually chose a file. How can I test if the user pressed cancel instead?
With oSht On Error Resume Next Set oPDF = .OLEObjects.Add(ClassType:="AcroExch.Document.DC", Link:=False, DisplayAsIcon:=True, IconFileName:= _ """C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"" ""%1""" _ , IconIndex:=0, IconLabel:="Adobe Acrobat Document", Left:=cLeft, Top:=cTop, Height:=50, Width:=50) On Error GoTo 0 If oPDF Is Nothing Then EventsOn Exit Sub End If