Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save HTML progress Log? 1

Status
Not open for further replies.

sn0rg

IS-IT--Management
Joined
Aug 5, 2005
Messages
95
Location
GB
I'm using the code:
Code:
Set objExplorer	= CreateObject("InternetExplorer.Application")

to create an IE window, and write the progress of scripts into it. How can I save this file as an HTML page after the script completes?

Thanks
 
Thanks PHV. I decided in the end to create a replica, via the FileSystemObject at the end of the script. Here's a sample script, note the final lines of code are the important ones:

Code:
Option Explicit
Dim objExplorer, X, strTop, strInner, objFSO, oStrm1
Set objExplorer = CreateObject("InternetExplorer.Application")

objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width= 800
objExplorer.Height = 400
objExplorer.Left = 1
objExplorer.Top = 1
objExplorer.Visible = 1
objExplorer.Document.BGColor="#808080"
objExplorer.Document.FGColor="#FFFFFF" 

strTop = "<font face=""arial"" size=""1"">"
strTop = strTop & "<font size=""5""><center>" & wscript.scriptname & " - Commencing run at " _
& Time & " on " & Date & ".</center><font size=""3""></p>"
strInner = strTop
objExplorer.Document.Title = wscript.scriptname 
objExplorer.Document.Body.InnerHTML = strInner

X = 0

Do while X < 100
	strInner = strInner & "Line: " & X & "</p>"
	with objExplorer.Document
		.body.InnerHTML = strInner 
		.parentwindow.scrollTo 0,.body.scrollHeight
	end with
	x = x + 1
Loop

' Create the HTML File on disk.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oStrm1 = objFSO.CreateTextFile("c:\log.html",True)

oStrm1.writeline "<html>"
oStrm1.writeline "<HEAD><Title>" & wscript.scriptname & "</TITLE></Head>"
oStrm1.writeline "<Body BGColor=""#808080"" Text=""#FFFFFF"">"
oStrm1.writeline strInner
oStrm1.writeline "</BODY></HTML>"

oStrm1.Close

Set objFSO = Nothing
 
That is a valid hack to bypass saveas dialog. But, you can do it more easily and more overall consistently like this.
[tt]
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oStrm1 = objFSO.CreateTextFile("c:\log.html",True)
[blue]oStrml.writeline objectExplorer.document.documentElement.outerHTML[/blue]
oStrm1.Close
Set objFSO = Nothing
[/tt]
 
Thats more like it! Cheers Tsuji, works a treat, and was exactly what I was looking for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top