Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

save a webpage to file then reload from file.

Avatar of Oli999
Oli999 asked on
Visual Basic ClassicWeb BrowsersMicrosoft Excel
4 Comments1 Solution312 ViewsLast Modified:
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.