VBA - How to Save a PDF to a folder that opens thru an IE page
I am creating a VBA macro. The purpose of this macro is to open a webpage
and click on hyperlink and save the newly opened webpage in a separate
window (it opens in PDF format) to a particular folder. My code is able to
open a webpage and click on the hyperlink. But am stuck up with saving the
newly opened PDF webpage. Here is my code.
Sub Generate_PDF()
Dim objIE As SHDocVw.InternetExplorer
Dim OrgBox As HTMLInputElement
Dim objButton As HTMLButtonElement
Dim objLink As HTMLLinkElement
Dim PDF As Object
Dim Path As String
Set objIE = New SHDocVw.InternetExplorer
objIE.navigate "http://XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
objIE.Visible = True
Do While objIE.readyState < 4: Loop
Set OrgBox = objIE.document.getElementById("dDocName")
OrgBox.Value = "2021345"
Set objButton = objIE.document.getElementById("miniSearch")
objButton.Click
Application.Wait (Now + TimeValue("0:00:05"))
Set objLink = objIE.document.getElementById("searchResultCompositeIcon")
objLink.Click
Application.Wait (Now + TimeValue("0:00:30"))
Path = "C:\Documents and Settings\INTEL\Desktop\SP"
PDF.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT, Path ' geting
object variable or with block variable not set error in this line
End Sub
please help me in saving the PDF document to a folder. is there a way to
do this.?
No comments:
Post a Comment