Share via


Displaying Help Topics from an Office Assistant Balloon

You can use the Office Assistant to display a balloon containing buttons and labels that users can click to open custom Help topics. As with other methods of displaying custom Help topics, you can use the Help method of the Application object to display a custom Help topic in Excel and PowerPoint, but you must use an API call to HTML Help to display a custom Help topic in Word and Access.

The following procedure can be used from Excel or PowerPoint (if you replace ActiveWorkbook.Path with ActivePresentation.Path) to display a Help balloon with labels and buttons for two topics:

Sub HelpFromAssistant()
   Dim intTopic         As Integer
   Dim blnVisible       As Boolean
   Dim strMsg           As String
   
   blnVisible = Assistant.Visible
   
   ' Determine if the Assistant is already visible.
   If blnVisible = False Then
      With Assistant
         .Visible = True
         .Animation = msoAnimationIdle
      End With
   Else
      Assistant.Animation = msoAnimationIdle
   End If
   
   ' Display Help balloon with two buttons and store user's
   ' selection in intTopic.
   With Assistant.NewBalloon
      .BalloonType = msoBalloonTypeButtons
      .Heading = "Displaying Help Topics"
      .Text = "Select a topic:"
      .Labels(1).Text = "Topic One"
      .Labels(2).Text = "Topic Two"
      .Button = msoButtonSetCancel
      .Mode = msoModeModal
      intTopic = .Show
   End With
   
   ' Determine which button the user clicked and display the Help
   ' topic. This code works only in Excel 2000 or later because 
   ' it refers to
   ' a .chm file. Replace with a WinHelp 4.0 .hlp file if you also
   ' need this code to run in Excel 97.
   Select Case intTopic
      Case 1
         Application.Help ActiveWorkbook.Path & "\sample.chm", 2001
      Case 2
         Application.Help ActiveWorkbook.Path & "\sample.chm", 2002
   End Select
End Sub

The same code can be used from Word or Access if you replace the calls to the Help method of the Application object with calls to the HtmlHelp API to display the topics. For Word, the Select Case statements would look like this:

Select Case intTopic
   Case 1
      Call HtmlHelp(0, ActiveDocument.Path & "\sample.chm",       HH_HELP_CONTEXT, _
         ByVal 2001&)
   Case 2
      Call HtmlHelp(0, ActiveDocument.Path & "\sample.chm",       HH_HELP_CONTEXT, _
         ByVal 2002&)
End Select

In Access, you would use the Path property of the CurrentProject object to display a topic from a compiled HTML Help file located in the same folder as the current database. For example:

Call HtmlHelp(0, CurrentProject.Path & "\sample.chm", HH_HELP_CONTEXT, ByVal 2001&)

See Also

Working with Shared Office Components | Using the Office Assistant to Display Help | Using the Assistant with Access Run-Time Applications | Creating an Answer Wizard Index to Display Custom Help Topics from the Office Assistant | Working with Shared Office Components