Adding Icons and Bitmaps to Balloons

In the Assistant balloon, you can add bitmaps (.bmp files), Microsoft Windows metafiles (.wmf files), or built-in icons within the heading or body text. Icons and bitmaps make the information and tips within a balloon more interesting.

  1. Within the same With…End block you modified in the steps in the "Displaying Labels" section, add the following line just before the line that sets the BalloonType property:
  2. .Icon = msoIconTip
    

    You can set the Icon property to one of the following MsoIconType constants: msoIconAlert, msoIconAlertCritical, msoIconAlertInfo, msoIconAlertQuery, msoIconAlertWarning, msoIconNone, or msoIconTip. Tip, specified by msoIconTip, is an image of a light bulb, and Alert, specified by msoIconAlert, is an image of an exclamation mark (!).

    The icon appears at the upper-left side of the Assistant's balloon, just to the left of the balloon heading. If you don't want to display an icon, set the Icon property to msoIconNone.

  3. Switch to the Windows Explorer and navigate to the Chapter 12 practice file. Copy the file Assistnt.bmp to the C:\ folder.
  4. Assign a string variable to reference the location of a bitmap by adding the following line above the With…End block:
  5. sBitmapFile = "{bmp C:\Assistnt.bmp}"
    

    To specify a bitmap, use the syntax {bmp <filename>}, where <filename> represents a valid filename of an existing bitmap file. (If you want to specify a Windows metafile instead, change "bmp" to "wmf" in the syntax above and specify a valid filename to an existing Windows metafile.) This picture syntax is represented by a string, and you can assign it to a string variable or add it directly to a string within the Assistant balloon.

IMPORTANT
When you include a bitmap in an Assistant's balloon, you must give the bitmap a filename and pathname with no spaces. If the filename or pathname contains spaces, the Assistant's balloon may not be displayed.

Also, the filename specified above assumes that you have installed the practice files in that particular folder. If you installed them in a different folder, set the filename above to the correct location. You can set the filename to any valid bitmap file on your computer. If the filename isn't correct, the Assistant isn't displayed when you run the DisplayOfficeAssistant procedure.

  1. Declare the string variable sBitmapFile at the beginning of the DisplayOfficeAssistant procedure where the other variables are declared:
  2. Dim sBitmapFile As String
    

  3. To add the bitmap in the Assistant's balloon, concatenate the text of the third label (added in step 1 of the section "Displaying Labels") with the string variable sBitmapFile. You do this by typing & sBitmapFile at the end of the .Labels(3).Text assignment statement. The revised line looks like this:
  4. .Labels(3).Text = "To display these steps again, " & _
        "click the Assistant button. " & sBitmapFile
    

NOTE
To concatenate means to join two or more separate groups of characters into one string using an ampersand (&).

  1. Place the cursor in the DisplayOfficeAssistant procedure and press F5 to run it. You'll see the Assistant with an icon beside the balloon heading, and a bitmap in the third item of the numbered list.
  2. In the DisplayOfficeAssistant procedure, change the line setting the Text property to the following and rerun the procedure:
  3. .Text = "To conduct a file search, " & sBitmapFile & _
        "follow the steps outlined below."
    

    You can add the specified bitmap to any text within the Assistant's balloon. Simply concatenate any string specified anywhere in the DisplayOfficeAssistant procedure with the string variable sBitmapFile.

  4. Place the cursor in the DisplayOfficeAssistant procedure and press F5 to run it again. The balloon should appear as shown in the following illustration:

NOTE
The bitmap file needs to remain in the C:\folder as long as your program contains the line sBitmapFile = "{bmp C:\Assistnt.bmp}." If you commented out or removed this line, the program will work correctly and the Assistant's balloon will be displayed. Otherwise, if the line above was executed but you removed the bitmap file from its folder on your hard drive, the Assistant's balloon won't be displayed.