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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you run a .htm file with VB?

Status
Not open for further replies.

CommanderX

Programmer
Feb 5, 2003
7
0
0
GB
Hi!

I'm very new to visual basic 6.0 programming, and so far I havn't been very lucky. I am trying to create an 'Autorun' Disc for a friend but I keep running up against walls! My friend would like a VB popup box to open giving the option to run his program or not. This I have done, without trouble, the problem comes in running his program. The program he wants to run is a HTML document, so I need to run a .htm file. Now, am I just really ignorant, or is there a way to do this???

If someone could help me I would be really grateful! I really need an example of coding or a method of how else to do it! If you can help then thanks!

Thanks very much!

Commander X
 

You can use the shell function or either of the API's of ShellExecute or ShellExecuteEx to run the html file in the default application outside of your program. If you want to keep it within your program you can use the webbrowser control and the navigate method to load the file.

Good Luck

 
Hi Again!

As I said, I am new to VB, so please humour me if I am being daft, every time I try and use shell or ShellExecute, It gives me the message "Compile Error, Sub or Function not defined." Any ideas?

Commander X
 

To load the API viewer you need to goto the menu itme Add-Ins>API Viewer. If you do not see it in that menu then select Add In Manager and a dialog will come up. Look for VB6 API Viewer and in the lower right corner in the load options frame make sure that the Loaded/Unloaded and Load At Startup check boxes are checked and click on ok. Go back to the Add-Ins menu and select the VB6 API Viewer. Another dialog will come up. GoTo the File Menu and select Load Text File. The common dialog showopen will appear. You should see a Win32API.txt file, select it and hit OK. If you are prompted to convert it to an mdb file go ahead and do this (it will load faster in the future). Once it is loaded start typing shell... and you should see the listbox jump forward to Shell_NotifyIcon and a couple of entries lower you should see ShellExecute. Highlight it and if you have a module in your project click on the Add button. If you just have a form then just below the Add Button select Private and then click on the Add button. Then either CTRL+C or click on the copy button. Goto the general declarations of either your module or form where you will be using this API and paste the code into your project.

Now for a description of how to use this API start help and type in the API name, in this case ShellExecute and you will find this API's definition.

Good Luck


 
Public Sub htmlReport(html as string)
Dim Scr_hDC As Long
Dim Confile As String
Dim objexplorer As Object

Set objexplorer = CreateObject("InternetExplorer.Application")
objexplorer.Navigate html
objexplorer.ToolBar = 0
objexplorer.StatusBar = 0
objexplorer.Width = 600
objexplorer.Height = 600
objexplorer.visible = 1
End Sub
 
Thanks very much Rorubin, but every time I put in the location of my file as a string, it comes up with "Expected, Identifier." Any clues???

Commander X
 
Believe it or not that is an error in your web page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top