Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

How To Open A HTML File In Browser? (Resolved)

for example when user click button1,
it open a file called "log.html" in the browser.

Shell "C:Program FilesInternet ExplorerIExplore.exe C:InetpubwwwrootNew Folderlog.html", vbNormalFocus

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Open An HTML File In A Browser Using Vb Code?
How to open an HTML file in a browser using vb code?
I know to ways:

1. Using ShellExecute API function
2. Using shell command

If use ShellExecute and have already open the browser (e.g. Internet Explorer) then the current site replaced and not open another window for display the HTML file.
If use shell command then must know which browser has the user available on computer. e.g. If user has installed internet explorer then can use shell "iexplore.exe" but if hasn't internet explorer then what happen?

How Do I Open The Default Web Browser**RESOLVED**
I have a button on my form. When the user clicks a button I need to open the default internet browser and display a certain page.

I have managed this using the shell command

Dim dblReturn As Double

dblReturn = Shell("C:Program FilesInternet Exploreriexplore.exe http://warehouse/qlinfo/CBSessionLis...UDENT&strYear=" & gstrAcadPeriod & "&strCode=" & Left(lstStudents.List(lstStudents.ListIndex), 11) & "&strIndiv=" & Trim(Right(lstStudents.List(lstStudents.ListIndex), Len(lstStudents.List(lstStudents.ListIndex)) - 11)), vbNormalFocus)
If dblReturn = 0 Then ' error
MsgBox "The details for " & lstStudents.List(lstStudents.ListIndex) & " could not be displayed.", vbInformation, "CMF"
End If

The problem is I am developing on W2K and the users are on NT4, this is a problem because their Iexplore.exe is in a different directory.

How can I open the default browser? remember this has to work on w2K and NT4

View Html Text In Browser Without File?

FlyGuy posted some code entitled:
Create HTML table from MSFlexGrid control

The code generates a html flexgrid tags n all into a string.

I would like to place this into a WebBrowser from vb6.

I can save the text as a file with a .html extention and set the browser to open the file.

Is there a way to view the .html by assigning the text to the browser without having to save the text to a file first?

Is there another control that would allow me to do this?

Code 4 Opening Html File In Web Browser
hi dear
can u tell me how can I open an html file in web browser if a person click on button. i have to write code in it's urgent.

thanks in advance.


Load Html From Resource File Into Default Browser
Anyone know if html files stored in resource files can be loaded into an external browser if the res file is compiled into the exe not a dll.

for example using shellexecute to call a resource such as

"res://" & app.path & " est.exe/help.htm"

Launch Default Browser And Read An HTML File

With VB6, I want to launch the default web browser on a system and read a
local html file into it.

Can someone explain how i do this ?


How To Position The Cursor When Loading The HTML File Contents Into A Web Browser - VB6

I load the contents of my HTML file into a web browser - and I want to postion my cursor in a particular place that may be a number of scrolled pages down the web browser - does anyone know how can I do this?


Open File Browser API And VBA ??!!
Can anyone give me a code or smtg , to call a open file dialog from comdlg or smtg , for use with vba ?

**RESOLVED** Is File Open - Probably Silly Question **RESOLVED**
Hey all,
I'm sorry if this question might sound a bit stupide or primitive but i'm really sleepy and my head is far from being clear today. Well, here it is: How can i determine if a certain file is open (In general, that is by another app)???

As i said, excuse me for this silly question, but this is one of those days where nothing really seems to be going your way

Thanx in advance folks

Open An Html File In Vb
hi, I want to open an html file that is in the same direcotry using VB.

When user clicks on the button, I want index.html to appear in the browser.

thank you..


Open Html File
How do I open an html file in a web browser?
I have a menu called help then user guide. The user guide was
designed in html format using Frontpage.
How would I go about opening this page in a web browser?

Any help or general direction to look would be greatly appreciated.

How To Open Html File From Vb??
can any one help me how to open html file from vb??thanx in adv.

How To Open A Html File In Vb With IE

I am Doing My Report Part In My Team.
Every Thing Was Completed.
Now I Want To Export The Report Into Html File .
Actually What I Did Is,I Ve Used The File System Object And I Created The Html File.Now How To Open That Html File In Internet Explorer Not In Web Browser Control.
Pls Give Me The Suggestion And Pls Tell Me Is It Right Method?


Open File From HTML
I want to open file txt and read it from HTML page using VBscript.

Does anybody Know something about that.


Michael Sakellis

Open Html File

how can i open a HTML file for reading. With that i mean showing the file.

Thank u

Open A Relative .html File
I want to open an html file (for example: index.htm) which is in the same folder as the .exe. So, i made an this .exe file, inserted a webBrowser component and written these lines for testing:

Private Sub Form_Load()
WebBrowser1.Navigate ("")
End Sub
...and it worked fine. However, i want to point it to my html file locally (index.html) and tried this one:

Private Sub Form_Load()
WebBrowser1.Navigate ("C:file.htm")
End Sub
...and hey! again it worked. But what i really wanted to do was point it relatively as i would do in an html site. So:

Private Sub Form_Load()
WebBrowser1.Navigate ("file.htm")
End Sub
...failure. The reason i want to do this is to be able to run it on a cd. What am i doing wrong? Thanx in advance.

Open A Relative .html File
I want to open an html file (for example: index.htm) which is in the same folder as the .exe. So, i made an this .exe file, inserted a webBrowser component and written these lines for testing:

Private Sub Form_Load()
WebBrowser1.Navigate ("")
End Sub
...and it worked fine. However, i want to point it to my html file locally (index.html) and tried this one:

Private Sub Form_Load()
WebBrowser1.Navigate ("C:file.htm")
End Sub
...and hey! again it worked. But what i really wanted to do was point it relatively as i would do in an html site. So:

Private Sub Form_Load()
WebBrowser1.Navigate ("file.htm")
End Sub
...failure. The reason i want to do this is to be able to run it on a cd. What am i doing wrong any suggestions? Thanx in advance.

How To Open An HTML File On My C Drive
I have the code to open an html page when i am trying to open websites. Like However I would like to open and html file located on my system in the default browser.

Sample Address - c:windowsdesktopindex.html

How would I write the code for this?


Open HTML File With Cmd_click
Can someone post the code to open an HTML file with Internet Explorer with a command click event please

Open A HTML File After Writing
I am generating a HTML file and then I would like to open it riht after closing the file. It does nothing. I tried putting "" instead of "C:" but it did not work either. Is there a correct way to do this, or a better way? I would like the browser to open it I think.

ShellExecute Me.hwnd, vbNullString, "CommonDialog1.fileName", _
vbNullString, "C:", SW_SHOWNORMAL

Edit Open Html File?
is it possible to edit an Open Html file? (in internet explorer)

Open Html-file With Parameters

to open an htm-file from my application, I use :

VB Code:
ShellExecute Me.hwnd, "open", "c:dataDrawChart.htm", "", "", 1

but how can i add parameters to that
f. i. I want to open the file like thus : "c:dataDrawChart.htm?1+a"

any ideas how to do this ?

Can I Use Autorun To Open An Html File?
ok ive burn a few cd's now, and dont have any re-recordables to hand

Can i use autorun.inf to start a web page/html file on the cd...for some reason its not working????

code im using is...



Actually Open Html File [edited]
Is it possible to "physically" open an html file as a preview of work you've done but not actually save it to that file?

also when you publish something to an html file if you click the cancel button while in the browse menu error pops up. Is it possible to fix this?

Open A Html File In A Textbox
How can i open a html file to a text box without showing the HTML Code???
Or anyone knows other method to open the html file????

Thanks in advance

Open HTML File Without Webbrowser
Hey all,

How can i open a .html in IE without using the web browser control!

I have the .html file i want to open it in the default browser!



Open HTML File From Menu
How can I open a HTML file with a click on a button.

Select File To Open Using Macro And Windows Browser?

What I need to do is write a bit into my macro that lets the user select the file they want to open (more accurately to name the path and filename of a workbook they wish to open) so that i can use the path and filename to open the XLS and then copy some of the data into my new workbook.

The files to import data from are not named with any convention, nor are they located on a fixed location (is a server which can change drive mapping letter depending on the user's computer!). What I wanted to do was have a window pop up (like the standard File, Open window) which allows the user to browse to their XLS and select it.

The macro would then set the path and filename into a variable so the XLS can be opened and referenced.

Is this possible?



Open Default Browser (New Window) BAS File Download!!!
Well i search this forum for some code to open the defualt browser, and into a new window and i couldn't find anything (though that doesn't mean that any help on this is not there!).

So i found a way to open the default browser, with a new window and made the code into a module (.bas) file.

I have tested this on the following browsers with no errors:
*Internet Explorer 6
*Netscape 7
*Opera 7

When the module is added to a project it is ran like this:




Not that hard is it?

Send Already Open IE Browser To Local .url Shortcut File
Ok, i've got a problem..again.
Hopefully someone can help me out.

I need to go through all windows on my task bar, find an IE browser window that has the caption that i'm looking for. Now I need to point that browser to a local .url internet shortcut (c:/location.url).

Any help will be greatly appreciated.

Dont Want To Open Excel File In IE Browser ?? Urgent..
Dear friends,

i am working in web application.
I am writing like this on aspx page to allow user to download a excel file.

<a href="http://cunet/excelOrders/abani.xls" >download</a>

My problem is , when user clicks on Download link, instead of pop up a save as window ( which allow user to save file in his maching) , its opening the excel file in browser only.
i dont want to open a file in browser..

i believe if my file is .zip then it open the save as pop up window, but since the extension is .xls its opeing the file in browser.

Pls help...

Piyush Jain

Stupid Question (How To Open HTML Help File)
I DID look for over an hour before giving up and showing my own stupidity! I have a form, let's call it frmMain, which has a menu item called mnuHelp, with a subitem called mnulstHelpTopics. Seems as basic as they come, when someone clicks helplist help topics from the main form I want my program to show the complied HTML help file I have already created and attahced to my program. I will ( later ) deal with context specific ones, but, how do I open the friggin help file to the main index page! (or at all for that matter!) I though I could get away with using a Shell command (I'm not liking Texaco much anymore anyway).

Thanks guys!

Open HTML Document As Text File
Hello, I have a problem with my code. It currently works fine, by
searching through a directory, finding every .html & .htm, searching
through that file for any href's, and then printing them into a
spreadsheet. The problem I have seemed to encounter though, is that
some files have the .html extension, but have IE icons, so the code
seems unable to search through the source code of them because if you
were to double click them they would simply come up in IE. Here is
some of the code that I have...

Sub CheckTextFilesForHREFs()

Globalindx = 1
'MsgBox "Press OK to begin report"
Dim WholeLine As String
Dim myPath As String
Dim workfile As String
Dim myR As Long

Set fs = Application.FileSearch
With fs
.LookIn = "C:Exelon"
.Filename = ".html"
.SearchSubFolders = True
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
Application.ScreenUpdating = False
For i = 1 To .FoundFiles.Count

ParseURL .FoundFiles(i)

Next i
Application.ScreenUpdating = True
MsgBox "There were no files found."
End If
End With
End Sub

Sub ParseURL(strFile As String)
Dim strTxt As String, lngTxt As Long, i As Long, oMatches
Dim ws As Worksheet, j As Long, k As Long, m As Long, oMatches2
Dim reg, oMatches3, reg2, txtTitle, txtLinkName, txtLine
Dim re, matches, match, d, uri, name
i = FreeFile

lngTxt = FileLen(strFile)
strTxt = Space(lngTxt)
Open strFile For Binary Access Read As #i
Get #i, , strTxt
Close #i

txtTitle = GetTitle(strTxt)

Dim indx
indx = 1
Dim tst
tst = GetHrefs(strTxt, strFile, txtTitle)

End Sub

Function GetURLAddress(ByVal TextToSearch) As String
Dim Start, Length
Start = InStr(1, TextToSearch, "href=", vbTextCompare) + 6
Length = InStr(1, TextToSearch, """ ", vbTextCompare) - Start
If Length < 0 Then
Length = InStr(1, TextToSearch, "'>", vbTextCompare) - Start
End If
If Length < 0 Then
GetURLAddress = ""
GetURLAddress = LTrim(RTrim(Mid(TextToSearch, Start, Length)))
End If
End Function

How Can I Open A Html File By Pressing A Button?
How can I open a html file by pressing a button?
For Example,I want to open "C: emp.html" by simply pressing a button.
I want to know if it is possible.

How Do I Refer To An External Program Like A Browser To Open My Displayed File
I need the displayed file in richtextbox1 to beable to be opened by an external program like a browser... at the click of a button..... any ideas?

*RESOLVED* Need A QUICKIE! - Opening An HTML File
I hope this is a quickie! I have searched the forum, but I can't find an example that I
understand(!) that does what I want, which is...

I want to open an html file from a click event using the default browser.

What I found is

'following placed in a module
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long,
ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory
As String, ByVal nShowCmd As Long) As Long

'following line placed on mnu click event
ShellExecute Me.hwnd, "open", App.PATH & "/index.html", Chr$(0), Chr$(0), 1

I have never used the shell before, so I have no idea what any of this means. I just want
the index.html to open in the browser from a click event in my app.



Need Help Opening HTML File In IE Using Excel Vba **RESOLVED
I have an excel spreadsheet that I need to make a Help File for. Currently I added and option for "Macro Help" in one of my toolbars on the spreadsheet so a user can select it, but right now it is pointing to a file to read yet. I was handed a spreadsheet and a word document that contains the Help documentation for that spreadsheet. I was originally thinking that I would just open the word document through VBA which I know how to do, but this assumes that I know where the user is placing that file since I would have to hard code the file path. So then i got to thinking that I could somehow embed html code in an excel subroutine, open IE, and then display the information when the user selects the help option. I haven't found a way to do this yet. I want to try and stay away from having the VBA code generate the document, I would rather have the code in the module and then display it as a webpage if possible. I am new to how application like excel and word reference these types of documents, so any help would be appreciated.

Anyone have any ideas?

Edited by - goodolE22 on 6/2/2004 12:52:27 PM

Open And Search A .html Saved File On Hardrive
Does anyone know how to search an html file for a certain string?

Open A Saved .html File Using A Command Button
I am using VB6.

I have saved a page from the Internet using Microsoft Internet Explorer. This saved page consists of a .html file and a folder that contains all the gifs, etc.

I would like to use this saved Internet page in my application.

Specifically, I would like for the user to click on a button, have his internet browser launch, and have my saved internet page appear in his browser. So, this page would appear whether the user was connected to the Internet or not.

I would be very grateful for ideas on how best to do this.

Thanks in advance.

Question About: Open HTML File & Size Of Dialog
I know now how to open a html file from within Visual Basic only not how to set the size of the dialog.
At this point it's starting in Full Screen...

How can I set the size of the Internet Explorer dialog in Visual Basic?

Thanks in advance,

Lance Peterson

Displaying HTML Text From Memory Not A File. **RESOLVED**
I have searched the forum but my question has not been answered full yet.

I need to display HTML code in something.
The HTML is generated at runtime. One option is to save to a temp file and load it with the webbrowser. I don't want to do that as it is sensitive data.

Any other ideas?

How Do I Open An Unpublished HTML File On Form Load Event?
I have a Swish Flash Movie That I exported and Converted to an HTML file. If I put this file in the same directory as my program is there any way I can call it on Form1's load event?.......

Using Excel To Open HTML File (Retain Cell's NumberFormat)
Hi all,

Thanks in advance for any answers to my enquires !

Due to client's requirement, i need to use MS Excel to open Html Files.

I noticed that during the process of opening the HTML File cell number format are converted to general format.

For eg. The HTML Format is as below
0001 / Testing Product/ 12 /

When exported to Excel it becomes this
1 / Testing Product / 12 /

Notice that 0001 becomes 1, which is wrong..

ps. Im using MS Excel XP.

Is that anyway in which i can change the setting of my Excel Application or Source Code for the correct format (0001) to be loaded to excel instead of (1)

my source code is as per below

    Dim FromWsheet As Excel.Worksheet
    Dim FromWBook As Excel.Workbook
    Dim tmpExcelApp As Excel.Application

    Set tmpExcelApp = New Excel.Application
    Let tmpExcelApp.Visible = True

    Set FromWBook = tmpExcelApp.Workbooks.Open(HTML Path) ' Open the Html File
    Set FromWsheet = FromWBook.Sheets(1) ' By Default is the First Sheet

Open File &amp; Start Reading From Mid File / Resolved / Solution Posted

Thanks for the input. My application reads the file line by line, sends the code to the buffer on a Motion Controller card and then temporarily goes into the by-pass mode. When the buffer has received the code then the Looping file resumes writing.

What I was wanting to do, and now can do, is to scroll down to a line of code in the G code window and start the cycle from that point. By the way the text in the yellow banner is always current with the line of code ( shown NotePad ) that is being processed. The code shown in Notepad was derived from the G code shown in the black window. Not only am I reading the code I'm also re-writing it as it's being read. I'm also reading the G code text ( yellow text ) and making some low level commands as it scrolls.

Now I'm sure that you understand all of this. Right?


Code: If FileLoaded = True Then
  fnum = FreeFile
  Open App.Path & "File.dmc" For Input As #fnum
    Do While Not EOF(fnum)
        FileRunning = True
        If StopFile Then FileRunning = False: Close #fnum: Exit Sub
        If DoLoop = True Then GoTo NextLine Else GoTo Pass
        Line Input #fnum, dmcLine
        dmcLine = Trim(dmcLine)
        If Mid(dmcLine, 1, 1) = "N" Then
          If Val(Mid(dmcLine, 2, InStr(dmcLine, ":") - 2)) >= LN Then DoWrite = True
          dmcLine = Replace(dmcLine, Mid(dmcLine, 1, InStr(dmcLine, Chr(32))), "")
        End If
        If DoWrite = False Then GoTo Pass
        If InStr(dmcLine, "M30") Then
          M30 = 1
          If Not Locked And InStr(dmcLine, "P") Then Locked = True: _
          Repeat = Val(Mid(dmcLine, 5, InStr(dmcLine, ":") - 1))
          dmcLine = Mid(dmcLine, InStr(dmcLine, ":") + 1, Len(dmcLine))
        End If
        If Mid(dmcLine, 1, 2) = "G5" Then
          strG50 = " " & Mid(dmcLine, 1, InStr(dmcLine, ":") - 1)
          dmcLine = Mid(dmcLine, InStr(dmcLine, ":") + 1, Len(dmcLine))
        End If
        cBuffer.Append dmcLine & vbCrLf: 'txtDMCBuffer = cBuffer.ToString
        If Mid(dmcLine, 1, 2) = "AM" Then
          dmcLine = ""
          DoLoop = False
          If n = 0 Then n = 1: dmcShell1.DMCCommand = "Download=1": gLines = gLines - 1
        End If
    FileRunning = False
    Close #fnum

Edited by - ServoWizard on 11/23/2004 9:51:24 AM

Resolved - Attempting To Download Large HTML Source To A .txt File
ok, I've got an app I'm trying to write that is supposed to take the HTML source from a specific website and save it as a .txt file so I can then search it and pull out the data I want to put into an Access database. I've got everything working except for the first part. Here's the code I've got for downloading the source and saving it as a .txt file:

Code: Dim vFile As Variant
    chann = FreeFile

    CommonDialog1.DefaultExt = "TXT"
    CommonDialog1.Filter = "Text files (*.TXT)/*.TXT"
    CommonDialog1.ShowSave 'display Save dialog
    If CommonDialog1.FileName <> "" Then
        Open CommonDialog1.FileName For Output As #chann
        vFile = Inet1.OpenURL("(specific internal company website that I probably shouldn't actually post on a public forum)", 1)
        Print #chann, vFile 'save string to file
        Close #chann 'close file
        FileName = CommonDialog1.FileName
    End If
    MsgBox "Finished"

Now, when I manually go to this specific website, right-click, and "View Source", it gives me a .txt file of the HTML source. However, when I run the program to do this automatically, it merely gives me a .txt file filled with "?"s and a few other miscellaneous characters. As a note, the source file is large. It's roughly 1.3 million characters. Anyone have any ideas? I'm kind of proud of how far I've gotten with the rest of the program, considering the fact that I'm relatively new to VB, but it's kind of a moot point if I can't get this part working. Thanks for any help you folks can give me.


Edited by - Katros on 8/25/2004 9:46:46 AM

Registering File Type And Open The File **Resolved**
Hello all
looking for "Registering an extension in windows", I came across this :

VB Code:
Public Sub AssociateFileExtension(Extension As String, _PathToExecute As String, ApplicationName As String)Dim sKeyName As String 'Holds Key Name in registry.Dim sKeyValue As String 'Holds Key Value in registry.Dim Ret&Dim lphKey&Ret& = InStr(1, Extension, ".")If Ret& <> 0 ThenMsgBox "Extension has . in it. Remove and try again."Exit SubEnd If sKeyName = ApplicationNamesKeyValue = ApplicationNameRet& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)Ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&) sKeyName = "." & ExtensionsKeyValue = ApplicationNameRet& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, _lphKey&)Ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&) sKeyName = ApplicationNamesKeyValue = PathToExecute & " %1"Ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, _lphKey&)Ret& = RegSetValue&(lphKey&, "shellopencommand", _REG_SZ, sKeyValue, MAX_PATH) sKeyName = ApplicationNamesKeyValue = App.Path & "" & App.EXEName & ".exe,0"Ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, _lphKey&)Ret& = RegSetValue&(lphKey&, "DefaultIcon", REG_SZ, _sKeyValue, MAX_PATH) SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0End Sub 'This will remove the file associations created above:Public Sub UnAssociateFileExtension(Extension As String, _ApplicationName As String)Dim sKeyName As String 'Finds Key Name in registry.Dim sKeyValue As String 'Finds Key Value in registry.Dim Ret&Ret& = InStr(1, Extension, ".")If Ret& <> 0 ThenMsgBox "Extension has . in it. Remove and try again."Exit SubEnd If sKeyName = ApplicationNameRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName & _"DefaultIcon") sKeyName = ApplicationNameRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName & _"shellopencommand") sKeyName = ApplicationNameRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName & _"shellopen") sKeyName = ApplicationNameRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName & _"shell") sKeyName = ApplicationNameRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName) sKeyName = "." & ExtensionRet& = RegDeleteKey(HKEY_CLASSES_ROOT, sKeyName) SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0End Sub

the problem is, what should I do with it??
how can I register a file type with my program??

in my program, i have an OPEN button, that uses a CommonDialog to open the file. If i can register file type, how can tell my program what to do with it??

thanks in advance

Open Of .RES File (RESOLVED)
I have a .res file in my vb 6 project
may i know what program or tools can i use to open the file to edit?

[Resolved... Unresolved... Resolved... Unresolved...] Open A File By Drag &amp; Drop
I want to open a file by dragging it and dropping it into an app's main form. I know it's the OLEDragOver event that's triggered, but then I need to know the name of the selected file before I can proceed to read and parse it. How can I pass this information to the app?

Open A File For Append? (Resolved)
is there a way to open a file for append?

Open "c: emp
ead.txt" for input as #1
Open "c: empwrite.txt" for output as #2

Any helps would be greatly appreciated,

Copyright 2005-08, All rights reserved