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!

Open html file via vbs file? 2

Status
Not open for further replies.

FancyPrairie

Programmer
Joined
Oct 16, 2001
Messages
2,917
Location
US
I want to place a shortcut on the user's desktop that will open an html file. However, I want the window to be opened to given size. I can do this from vbscript within another html file (window.showModelessDialog). But how would I do it via a vbs file?
 
Hi

If you would like to open / display a html file stored localy, this might work for you:
Code:
dim objExplorer

open_ie
objExplorer.Document.Body.InnerHTML = HTMLTextfile("c:\test\test.htm")

'-------------------------------------------------------------------------------------------------------------------------------
'	open ie
'-------------------------------------------------------------------------------------------------------------------------------
sub open_ie
	Set objExplorer = CreateObject("InternetExplorer.Application")
		with objExplorer
			.Navigate "about:blank"
			.ToolBar = 0
			.StatusBar = 0
			.Width=1200
			.Height = 600 
			.Left = 1
			.Top = 1
			.Visible = 1
		End with
end sub


'-------------------------------------------------------------------------------------------------------------------------------
'	open fileobject
'-------------------------------------------------------------------------------------------------------------------------------
function HTMLTextfile(pathfile)
	Const ForReading = 1
	HTMLScr = ""
	pathfile = trim(pathfile)
	Set objFSO = CreateObject("Scripting.FileSystemObject")
	set objFile = objFSO.GetFile(pathfile)
	Set objReadFile = objFSO.OpenTextFile(pathfile,ForReading)
	Do Until objReadFile.AtEndOfStream
		HTMLScr = HTMLScr & objReadFile.ReadLine
	Loop
	HTMLTextfile = HTMLScr
	objReadFile.Close
end function

If the html file is a internet / intranet page I will have to search for a solution myself.

Hope I could be of assistance
Regards
Thomas
 
There shouldn't be a need to read the html file through other agent like fso. Navigate to a file resource is admissible.

[tt]with objExplorer
.Width=800
.Height=600
.Left=150
.Top=50
.Visible=true
.navigate "c:\test\test.htm"
'navigate "file:///c:\test\test.htm" 'alternative
end with
do while objExplorer.readystate<>4 : wscript.sleep 50 : loop
'do the rest
[/tt]
 
Ups, of course. Thank you Tsuji for correcting my mistake.
Sorry FancyPrairie for leading You in the wrong direction.

Regards
Thomas
 
Thanks to both of you. It works just like I wanted it to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top