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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
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
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

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
Back
Top