djl0525
Well-known Member
- Joined
- Dec 11, 2004
- Messages
- 1,240
The code below was copied from one of John Walkenbach's CDs. It's working fine, but I have a few questions about it.
1. What does the Option Explicit do? More to the point, what does the Public Const line do? My file has nothing to do with elephants. I know I can modify it, but what will happen if I delete that line?
2. I want to close the Assistant if the workbook from which it was launched is closed. And I want to hide it if the workbook is no longer the active workbook (and then come back if the workbook becomes active again). In other words, I want the help file that is launched by this code to be context sensitive to the workbook that launched it. How do I do that?
3. Can I change the color of the help ballon from the default yellow to something else?
Thank you in advance for your consideration. Here is the code:
Option Explicit
Public Const APPNAME As String = "Elephants R Us"
Dim Topic
Dim HelpSheet
_________________________________________________________
Sub ShowHelp()
Set HelpSheet = ThisWorkbook.Worksheets("HelpSheet")
Application.Assistant.On = True
Topic = 1
With Assistant.NewBalloon
.Heading = "Help Topic " & Topic & ": " & vbCrLf & HelpSheet.Cells(Topic, 1)
.Text = HelpSheet.Cells(Topic, 2)
.Button = msoButtonSetNextClose
.BalloonType = msoBalloonTypeButtons
.Mode = msoModeModeless
.Callback = "ProcessRequest"
.Show
End With
End Sub
_________________________________________________________
Sub ProcessRequest(bln As Balloon, lbtn As Long, lPriv As Long)
Dim NumTopics As Integer
NumTopics = Application.WorksheetFunction.CountA(HelpSheet.Range("A:A"))
Assistant.Animation = msoAnimationCharacterSuccessMajor
Select Case lbtn
Case msoBalloonButtonBack
If Topic <> 1 Then Topic = Topic - 1
Case msoBalloonButtonNext
If Topic <> NumTopics Then Topic = Topic + 1
Case msoBalloonButtonClose
bln.Close
Exit Sub
End Select
With bln
.Close
Select Case Topic
Case 1: .Button = msoButtonSetNextClose
Case NumTopics: .Button = msoButtonSetBackClose
Case Else: .Button = msoButtonSetBackNextClose
End Select
.Heading = "Help Topic " & Topic & ": " & vbCrLf & HelpSheet.Cells(Topic, 1)
.Text = HelpSheet.Cells(Topic, 2)
.Show
End With
End Sub
1. What does the Option Explicit do? More to the point, what does the Public Const line do? My file has nothing to do with elephants. I know I can modify it, but what will happen if I delete that line?
2. I want to close the Assistant if the workbook from which it was launched is closed. And I want to hide it if the workbook is no longer the active workbook (and then come back if the workbook becomes active again). In other words, I want the help file that is launched by this code to be context sensitive to the workbook that launched it. How do I do that?
3. Can I change the color of the help ballon from the default yellow to something else?
Thank you in advance for your consideration. Here is the code:
Option Explicit
Public Const APPNAME As String = "Elephants R Us"
Dim Topic
Dim HelpSheet
_________________________________________________________
Sub ShowHelp()
Set HelpSheet = ThisWorkbook.Worksheets("HelpSheet")
Application.Assistant.On = True
Topic = 1
With Assistant.NewBalloon
.Heading = "Help Topic " & Topic & ": " & vbCrLf & HelpSheet.Cells(Topic, 1)
.Text = HelpSheet.Cells(Topic, 2)
.Button = msoButtonSetNextClose
.BalloonType = msoBalloonTypeButtons
.Mode = msoModeModeless
.Callback = "ProcessRequest"
.Show
End With
End Sub
_________________________________________________________
Sub ProcessRequest(bln As Balloon, lbtn As Long, lPriv As Long)
Dim NumTopics As Integer
NumTopics = Application.WorksheetFunction.CountA(HelpSheet.Range("A:A"))
Assistant.Animation = msoAnimationCharacterSuccessMajor
Select Case lbtn
Case msoBalloonButtonBack
If Topic <> 1 Then Topic = Topic - 1
Case msoBalloonButtonNext
If Topic <> NumTopics Then Topic = Topic + 1
Case msoBalloonButtonClose
bln.Close
Exit Sub
End Select
With bln
.Close
Select Case Topic
Case 1: .Button = msoButtonSetNextClose
Case NumTopics: .Button = msoButtonSetBackClose
Case Else: .Button = msoButtonSetBackNextClose
End Select
.Heading = "Help Topic " & Topic & ": " & vbCrLf & HelpSheet.Cells(Topic, 1)
.Text = HelpSheet.Cells(Topic, 2)
.Show
End With
End Sub