longccc
08-13-2010, 07:56 AM
Hi, I want to write a vba code to automatically download something from the website. I did the following:
open the website
click the download button (which is a java script, NOT the link to the file)
then here comes the problem, after i click the button, it will pop out a msgbox, I need to click the "save" button on the msgbox and choose the path to save. Is there anyway I could make this process automatic?
the code until the clicking step is the following:
Dim myIE As shdocvw.InternetExplorer
Dim myLink As MSHTML.HTMLLinkElement
'check if page is already open
Set myIE = GetOpenIEByTitle(myPageTitle, False)
If myIE Is Nothing Then
'page isn't open yet
'create new IE instance
Set myIE = GetNewIE
'make IE window visible
myIE.Visible = True
'load page
If LoadWebPage(myIE, myPageURL) = False Then
'page wasn't loaded
MsgBox "Couldn't open page"
Exit Function
Else
End If
Else
If RefreshWebPage(myIE) = False Then
End If
End If
Open_Explorer = True
For Each myLink In myIE.Document.Links()
myLink.Click
Next myLink
Thank you!
open the website
click the download button (which is a java script, NOT the link to the file)
then here comes the problem, after i click the button, it will pop out a msgbox, I need to click the "save" button on the msgbox and choose the path to save. Is there anyway I could make this process automatic?
the code until the clicking step is the following:
Dim myIE As shdocvw.InternetExplorer
Dim myLink As MSHTML.HTMLLinkElement
'check if page is already open
Set myIE = GetOpenIEByTitle(myPageTitle, False)
If myIE Is Nothing Then
'page isn't open yet
'create new IE instance
Set myIE = GetNewIE
'make IE window visible
myIE.Visible = True
'load page
If LoadWebPage(myIE, myPageURL) = False Then
'page wasn't loaded
MsgBox "Couldn't open page"
Exit Function
Else
End If
Else
If RefreshWebPage(myIE) = False Then
End If
End If
Open_Explorer = True
For Each myLink In myIE.Document.Links()
myLink.Click
Next myLink
Thank you!