-
Doing it for the active web page is a little tricky if you didn't create the instance of IE yourself. It that something that can be worked around?
If so then either of these work with IE8. If not post back and we'll work on it
[vba]Option Explicit
Private Declare Function URLDownloadToFileA Lib "urlmon" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Sub Example1()
DownloadFile "http://www.google.com", "c:\Test\goog.txt"
Shell "notepad.exe ""c:\Test\goog.txt""", vbMaximizedFocus
End Sub
Public Sub Example2()
'Requires reference to Microsoft Internet Controls
Dim ie As SHDocVw.InternetExplorer
'Microsoft HTML Object Library
Dim doc As MSHTML.HTMLDocument
Set ie = New SHDocVw.InternetExplorer
ie.Navigate "www.google.com"
Do Until ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Do While doc Is Nothing
Set doc = ie.Document
Loop
MsgBox doc.body.innerHTML
ie.Quit
End Sub
Private Function DownloadFile(URL As String, LocalFilename As String) As Boolean
'Thanks Mentalis
Dim lngRetVal As Long
lngRetVal = URLDownloadToFileA(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
[/vba]
Cordially,
Aaron
Keep Our Board Clean! - Please Mark your thread "Solved" if you get an acceptable response (under thread tools).
- Enclose your code in VBA tags then it will be formatted as per the VBIDE to improve readability.
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