-
how to use vba to automatically download a file
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!
-
Welcome to the forum! Please use the VBA button to add code tags and paste code between them.
Without the real website URL, there is no way to help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules