simple question: how to open a htm file in vba

Biedubbeljoe

Active Member
Joined
Aug 16, 2004
Messages
308
How do I open a htm file in vba,
while my active workbook/sheet stay'open?

Private Sub ShowHelp_Click()
Unload Me
Show.HelpFile.htm
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You could use the Shell statement:
Code:
Sub Test()
Dim retval
    
    retval = Shell("C:\Program Files\Internet Explorer\iexplore.exe C:\all.html")
End Sub
Replace the path to Internet Explorer and the html file.

Orr you could try this

ActiveWorkbook.FollowHyperlink "C:\all.html"
 
Upvote 0
I took the second option, because the helpfile is in the same directory as the xls file.
And it worked! Thanks.
 
Upvote 0
You can also associate a Help file with your workbook.

In the VBE click your workbook in the Project window and choose Tools|VBA Project Properties. On the General tab type or browse for your help file name in the Help File Name box and click OK. That done you can use the HelpContextID property of your CommandButton to assign it a specific topic in your Help file.
 
Upvote 0
The followhyperlink worked fine with my pc but not with others, so I set up Andrews posibility.
In the VBE click your workbook in the Project window and choose Tools|VBA Project Properties. On the General tab type or browse for your help file name in the Help File Name box and click OK. That done you can use the HelpContextID property of your CommandButton to assign it a specific topic in your Help file.
I did all that, my helpfile is a word.doc and it's in the same directory as the xls file.
What do I have to put into my:
code:
---------------------------------
Private Sub ShowHelp_Click()
Unload Me

End Sub
---------------------------------
because it doesn't work..:(
The problem is that I can't do the shell option, because the two files can be used in whatever directory, but always together. A fixed path is no option.
 
Upvote 0
ASFAIK the file actually has to be a help file with the extension hlp. There are various tools for creating these.

When you say the hyperlink worked on your PC and not others what was the problem?
 
Upvote 0
OK will look for the tool to convert to hlp of chm file.
I prefer not to look futher after I see that the error has something to do with application not found. The help file must be seen and found at all times..agree..:)
 
Upvote 0
Ok, have made a help button on my sheet.
In vba I see:
code:
---------------------------------
Private Sub ShowHelp_Click()
Unload Me

End Sub
---------------------------------
In my project -> ShowFile -> HelpContextID = 1
project properties -> helpfile.chm -> ID =1

But if I push the button nothing happen..:(
 
Upvote 0
The method I described is designed to work if the user presses F1 when the control has the focus.

Try this:

Code:
Private Sub ShowHelp_Click()
   Application.Help ThisWorkbook.VBProject.HelpFile, 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,153
Messages
6,176,728
Members
452,740
Latest member
MrCY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top