How to use VBA save a web page referred to by a hyperlink in

Brian

Board Regular
Joined
Apr 24, 2002
Messages
113
Source: xls file that contains links to files and web pages.

Task: Save a copy of all linked files and web pages (intranet) to a directory on the local hard drive. (So that I can take all of the files on the road with me.)

Status: I can save all linked files to my hard drive, but I am unsure how to save the linked intranet pages. (Follow link, then use iexplorer file > save as command? How to control ie? How to switch between excel and ie?)

Thanks in advance,

Brian
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Brian

Board Regular
Joined
Apr 24, 2002
Messages
113
Thanks,

I turned on 'Tools > References > Microsoft Internet Controls.

I was able to open a link in explorer:

Hlink = "http://www.mrexcel.com"
'Get an instance of Internet Explorer 3.0
Set MyBrowser = New SHDocVw.InternetExplorer
MyBrowser.Visible = True
MyBrowser.Navigate Hlink

But I have not been able to determine how to save the file (saveas does not work, could not get OLECMDID_SAVEAS to work.)

Have not found anything useful yet.

Regards,

Brian
 

Brian

Board Regular
Joined
Apr 24, 2002
Messages
113
Thanks Juan!

I had found references to OLECMDID_SAVEAS but was clueless how to use it.

When I run the following line, i get the error "Run Time Error 2147221248 (80040200)Method ExecWB of object Iwebbrowser2 failed", but if I then click debug, play and click the iexplore window, then it works. It seems like I need to activate or select the iexplore window, but I have not yet found a way to do that.

MyBrowser.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, "d:tempxyz.htm"

And for the second method suggested, how does one save a string to a file?
 

Forum statistics

Threads
1,144,214
Messages
5,723,057
Members
422,476
Latest member
beck85

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top