MartyConnelly
martyconnelly at shaw.ca
Mon Jun 13 20:24:17 CDT 2005
Ah you want to save the images as well , doing a complete "saveas" will save multiple html files and directories, so you might want a single archive .mht file. The reason the "saveas" only allows saves to a text based html file is a security feature. Otherwise the little darlings could save binary excutables onto your disk. However if you want to risk it, this replacement code will work, sendkeys has it own flaws. It may only work if your browser allows scripting of unsafe ActiveX Works for me IE 6.01 with Medium security and MS scripting installed To get an mht archive file you will have to change code to tab around with sendkeys. Dim X As Object Set X = CreateObject("WScript.Shell") X.SendKeys ("%f") ' select IE File Menu X.SendKeys ("a") 'selects save as menu X.SendKeys ("{del}") 'delete filename X.SendKeys ("c:\temp\mycompletehtml") 'double slashes may be required if multi folder path X.SendKeys ("{Tab}") X.SendKeys ("{Tab}") 'get to save button X.SendKeys ("{ENTER}") ' comment this out to see what happens on screen Drawbridge, Jack: #CIO - BPI wrote: >Marty > >Thanks for info. It's close to what I'm looking for. >Have not seen the ".queryCommandEnabled" or ".execCommand" > >In your code > 'or alternate method that security may clobber, saves everthing with > fileopen box used > -With objExplorer.Document > -If .queryCommandEnabled("saveAs") Then .execCommand "saveAs", False, > "C:\temp\myurl.htm" > -End With > I'm trying to actually use File SaveAs Webpage, Complete. If you manually do a File SaveAs in Internet explorer, you'll see other options than (htm,html). >Your technique gives me (htm, html). Can you see any means of supplying/gettign other options? > >Thanks >jack > > >-----Original Message----- >From: accessd-bounces at databaseadvisors.com >[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of MartyConnelly >Sent: Friday, June 10, 2005 6:40 PM >To: Access Developers discussion and problem solving >Subject: Re: [AccessD] Automating - IE6 - File Save As -- Marty > > >You maynot be able to do this for security reasons on second method. >Ran this okay from WinXP SP2, Access97, IE6.0.2900 xpsp2 patches > >Here are two ways. > >'This gets around security limitations >'will only save between <body> </body> tags >CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\temp\myurlsaved.htm", >2, True).Write _ > objExplorer.Document.Body.innerHTML > >'or alternate method that security may clobber, saves everthing with >fileopen box used >With objExplorer.Document > If .queryCommandEnabled("saveAs") Then .execCommand "saveAs", False, >"C:\temp\myurl.htm" > End With > >Anywho here is some rough test code, that works both ways. >You can throw out all the commented objdocument code at bottom. > > >Sub testIESave(strpassHTML As String) >'------------------ >'testIESave "http://www.Viescas.com/" >Dim objExplorer As Object >Dim objDocument As Object >Dim strComputer As String > >Dim strReturn As String > >Set objExplorer = CreateObject("InternetExplorer.Application") > >'objExplorer.navigate "about:blank" >objExplorer.navigate strpassHTML >objExplorer.Toolbar = 1 'or 0 to turnoff toolbar turned off maynot save >all html source >objExplorer.StatusBar = 0 >objExplorer.Width = 800 >objExplorer.Height = 570 >objExplorer.Left = 0 >objExplorer.Top = 0 >objExplorer.Visible = 1 >'dont't need to navigate to file or http site >'just drop html string in document object >'objExplorer.Navigate "file://c:\temp\test.html" >'objExplorer.Navigate "http://www.Viescas.com/" >'objExplorer.Navigate "http://checkip.dyndns.org/" > >Do While (objExplorer.Busy) >Loop >Dim webtx As String >Dim strHTML As String >'will only save between <body> </body> tags >CreateObject("Scripting.FileSystemObject").OpenTextFile("C:\temp\myurlsmall.htm", >2, True).Write _ > objExplorer.Document.Body.innerHTML >'alternate method security may clobber saves everything >With objExplorer.Document > If .queryCommandEnabled("saveAs") Then .execCommand "saveAs", False, >"C:\temp\myurl.htm" > End With > >'Set objDocument = objExplorer.Document >'objDocument.Open >'objDocument.writeln "<html><head><title>My Continuous >Pictures</title></head>" >'you probably don't need all this but you could throw in some css >'objDocument.writeln "<body bgcolor='red';" & _ >' " { background-attachment: fixed; background-position: 97% >bottom; " & _ >' " background-image= 'url(logoBackGround.gif)';background-repeat: >no-repeat;" & _ >' " padding: 5px;font-family='Georgia';font-size: 80%;} >" > >'objDocument.writeln "<table width='100%'>" >'objDocument.writeln "<tr>" >'objDocument.writeln "<td width='20%'><b>Pictures</b></td>" >'objDocument.writeln "</tr>" >'objDocument.writeln "</table>" > >'objDocument.writeln "<h3>Method #2:</h3><img src = ""C:\Access >files\CandaceTripp\picture\shakes.bmp"" Width = ""150"" Height = ""75"" >alt = ""Random Image #4"" />" > >'objDocument.writeln strpassHTML >'objDocument.writeln "</body></html>" >'objDocument.Write() >'objDocument.Close >'MsgBox "finished" >Set objExplorer = Nothing >Set objDocument = Nothing > >End Sub > > >Drawbridge, Jack: #CIO - BPI wrote: > > > >>Have had no responses with original post. I believe it is a question of automating IE, and how to get to CommonDialog in order to do the File Save As. >> >>IE does a fantastic job of removing relative links and downloading a clean set of files when using the File Save As webpage complete option. I do not want to do the File saves manually. There must be a means to automate this in VBA??? >> >>Any advice/help on this would be greatly appreciated. >> >>Thanks, >> >>jack >> >>-----Original Message----- >>From: accessd-bounces at databaseadvisors.com >>[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Drawbridge, >>Jack: #CIO - BPI >>Sent: Thursday, June 2, 2005 3:01 PM >>To: Access Developers discussion and problem solving >>Subject: [AccessD] A2K talking to IE6 - File Save As >> >> >>Looking for help/advice or sample code to open IE6 from code in A2K. Am interested in how to do a File| Save As Webpage, Complete. >>We have a database of 60000 companies and want to put extracts of selected 100-500 companies (html and graphics etc) onto a CD for use with Offline Browser. >> >>Can not figure out how to get to IE6 File | Save As. >> >>I have some code to open a page with IE browser and save all the links on the page. >> >>Any help would be appreciated. >> >>TIA >> >>jack >> >>'---- CODE to GET the Links from a given page ---- >>'--------------------------------------------------------------------------------------- >>' Procedure : GetLinks >>' DateTime : 2005-06-02 14:19 >>' Author : >>' Purpose : get all links from a named webpage URL >>'--------------------------------------------------------------------------------------- >>' >>Sub GetLinks() >> >>' ** need to set a reference to >>' ** Microsoft Internet Controls >> >> Dim IeApp As InternetExplorer >> Dim sURL As String >> Dim IeDoc As Object >> Dim i As Long >> >> 'Create new instance of IE >> Set IeApp = New InternetExplorer >> >> 'May wish to make IeApp visible >> 'apparently some things don't work >> 'unless it's visible >> IeApp.Visible = False >> >> 'define the page to open >> sURL = "www.diligens.com" >> >> 'navigate to the page based on URL >> IeApp.Navigate sURL >> >> 'Pause until the webpage is completely loaded >> Do >> Loop Until IeApp.ReadyState = READYSTATE_COMPLETE >> >> 'Create instance of Document object >> Set IeDoc = IeApp.Document >> >> 'Loop through the document's links collection. >> For i = 0 To IeDoc.links.Length - 1 >> Debug.Print IeDoc.links(i).href >> Next i >> >> 'Clean up >> Set IeApp = Nothing >> Set IeDoc = Nothing >>End Sub >> >> >> >> > > > -- Marty Connelly Victoria, B.C. Canada