Microsoft Office Tutorials and References
In Depth Information
Creating a Folder Tree Menu
' * * * * *¶
Option explicit¶
'Place in a separate module if unsure¶
'whether code will be used in Word 2000¶
'Word 2000 does not support adding pictures¶
'from file! Code in a separate module only¶
'compiles if it is called¶
Const IconPath As String = "C:\OffMacroBook\SampleFiles\"¶
' * * * * *¶
Sub AddButtonPicture(ctl As Office.CommandBarButton, filetype As
String)¶
'Variable declaration¶
Dim pic As IPictureDisp¶
Dim mask As IPictureDisp¶
Dim IconFile As String¶
'Add a picture to the button,¶
'based on the type of file¶
Select Case filetype¶
Case "Word"¶
IconFile = IconPath & "WordIcon.bmp"¶
Case "Excel"¶
IconFile = IconPath & "XLIcon.bmp"¶
Case "Powerpoint"¶
IconFile = IconPath & "PPTIcon.bmp"¶
Case "Graphic"¶
IconFile = IconPath & "GrphIcon.bmp"¶
Case Else¶
End Select¶
'Make sure the specified graphics file exists¶
If Dir(IconFile) <> "" Then¶
Set pic = stdole.StdFunctions.LoadPicture(IconFile)¶
Set mask = stdole.StdFunctions.LoadPicture(IconFile)¶
ctl.Picture = pic¶
End If¶
End Sub¶
Wrd
Follow these steps:
1. Copy the procedures to a module in a template or document. The
example file uses two modules. The code specific to Word 2002 and 2003
is contained in the second module. This routine is called only when the
version number indicates it is needed. Since the code is contained in a
separate module, it is not compiled until it is called.
2. Edit the file paths in the Const declarations to reflect what the macro
should do:
BaseFolderPath The top-level folder, the contents of which should
appear in the main menu drop-down
¾
Search JabSto ::




Custom Search