MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Adding Help file .hlp to Excel Macro

Posted by yogesh k. potdar on December 27, 2001 8:04 AM


How do I add a .hlp file as a Help file to an existing Excel Macro?? What format should it have??

thanks a lot!

Wish you all a very happy New Year!!


Posted by Joe Was on December 27, 2001 8:46 AM

Some Excel methods allow for help file code numbers or the addition of your own. Without your code on this post we can't help you their, but you can use data validation to trap errors and display help. Or you can add event comments to your macro to act as help?

Here is some code that works with adding comments, they might help?

Joe Was

Sub myComment()
'Add Comment to a cell range by "InPut Validation Message."
'This code is run by Hot-key = Ctrl-c
'Range("the cell address you want to comment").Select
With Selection.Validation
.Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "Your title here!"
.ErrorTitle = ""
.InputMessage = "Your Msg. here!"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub

Sub myTextCom()
'Add comment by "Scenario" for cells "D1 & D2."
'This code is run by Hot-key = Ctrl-t

ActiveSheet.Scenarios.Add Name:="myComm", ChangingCells:=Range("D1:D2"), _
Values:=Array("This is one Comment!", "This is Comment two!"), Comment:= _
"Created by Joe Was", Locked:=True, Hidden:= _
End Sub

Sub showMyComm()
'This will display the comments, loaded by "Sub myTextCom()" as the scenario(myComm)!
'This code is run by Hot-key = Ctrl-s

End Sub

Sub delTexComm()
'This will delete the scenario(myComm)comments displayed by "Sub ShowMyComm"!
'This code is run by Hot-key = Ctrl-d

End Sub
Sub addCellText()
'This code will simply add text to the selected cell.
'This code is run by Hot-key = Ctrl-x

'Comment-out to run for range!

'This code selects a cell range rather than the active cell range above!

ActiveCell.FormulaR1C1 = "This is one Comment!"

'Bold the comment.
ActiveCell.Font.Bold = True

'ActiveCell.FormulaR1C1 = "This is Comment two!"
'Bold the comment.
'ActiveCell.Font.Bold = True
End Sub

Sub sExcelCom()
'This code will display an excel comment.
'This code is run by Hot-key = Ctrl-e

With Range("E1").AddComment
.Visible = True
.Text "Cell comment E1"
End With
End Sub
Sub rExcelCom()
'This code will hide the Excel comment!
'This code is run by Hot-key = Ctrl-r

Range("E1").Comment.Visible = False
End Sub

You can add some of these sub's to your code or trap an event or error and display a help note with the above code samples. JSW