Question : save a webpage to file then reload from file.

Spreadsheet with a webbrowser on it. Need to navigate to a web page, save it to a file locally then reload it from the file later.

This is my code:-

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Sub SaveButton_Click()
  Dim returnvalue As Long
  dim url,filename as string
 
  url = Sheet1.WebBrowser1.LocationURL
  filename = "c:\testfile.htm"
  returnvalue = URLDownloadToFile(0, url, filename, 0, 0)
End Sub

Sub LoadButton_Click()
  Sheet1.WebBrowser1.Navigate2 ("c:\testfile.htm")
End Sub

When running the Save Sub it seems to work ok and saves the file however when click to re-load from file it takes about 30-40 seconds to load. It loads most of it then freezes for ages then finally loads the last little bit. Strangely it only does this when the computer is connected to the internet. If the internet is disconnected then it re-loads the page instantly without any problems. This isn't really practical though as I need to re-load the page instantly without having to disconnect or wait for ages every time.

Tried loading the saved file into IE when online it brings up warnings about active x and scripts running, I clicked to allow content and it eventually loads after about 30 seconds.

Any ideas on how to solve this would be greatly appreciated.

Answer : save a webpage to file then reload from file.

If it does the same thing when you open the saved file in IE, then it is not doing anything different.
When in offline mode /disconnected, it times out immediately when trying to load external js/css/images etc, so the base text of the page loads immediately.
Random Solutions  
 
programming4us programming4us