Avatar of hal60
hal60
 asked on

need to save the complete html of a webpage using ie using vba access

i am trying to save the complete webpage so it looks basically like a print screen, with all the formatting using vba.  I am using the internet explorer object.  I want it to save a copy like internet explorer does when you do a saveas from the internet explorer file menu and saving it as a webpage complete html.



S = IE.Document.documentElement.outerHTML ' get html file

Fname = "Test.html"
Open Fname For Output As #1
Print #1, S ' save the header file
Close #1
Microsoft ExcelMicrosoft Access

Avatar of undefined
Last Comment
darbid73

8/22/2022 - Mon
SOLUTION
Gustav Brock

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
hal60

ASKER
That did not work for my case. all it did was force me to login to the site. it is a secure website and it somehow doesn't like this method.
Gustav Brock

Well, you didn't mention anything about a login. Then you need the browser object.

I don't have code for that, sorry.

/gustav
Gustav Brock

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
darbid73

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
hal60

ASKER
i tried using Ie.Document.execCommand "SaveAs", True, X   it kind of works but you can't specify a destination file(goes to a default folder) .  the dialog save as comes up but prevents the code from continuing so i have to manually enter ok (which kind of defeats the purpose of automation), i would have liked to sned a key from the code.   I tried changing true or false which didn't matter.and  The only way a dialog box would come up is if i put a filename that didn't have a subfolder. for example  c:\test.htm would bring up dialog  but c:\TEST2\test.htm did not  weird
darbid73

That is why that person also asked the question.

The next person quotes from the information on that method...

"The Save HTML Document dialog cannot be suppressed when calling this method from script."
darbid73

Gustav's post #a41834404 is a solution to the question on downloading a file, however the author then added a further comment which meant that this solution could not be used.

Darbid's post at #a41851743 is a solution to the authors question and further comments. The link forum question offer 2 solutions, it appears the author has tried the first solution as he comments above he does not like it.  The second solution is exactly what he needs and I assume he is using this and it suits him which is why he has not replied.

I suggest a split of points between Gustav and Darbid.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.