Microsoft Office Tutorials and References
In Depth Information
Creating a Folder Tree Menu
'Determine whether the button already¶
'exists in the specififed toolbar,¶
'based on its caption¶
For Each c In cb.Controls¶
If c.Caption = s Then¶
buttonExists = True¶
Exit For¶
End If¶
Next c¶
End Function¶
' * * * * *¶
'Common macro executed by all buttons¶
'for valid file types¶
Sub ProcessFile()¶
Dim ctl As Office.CommandBarButton¶
Dim filetype As String¶
Dim filename As String¶
'The ActionControl property gives us¶
'the button that was clicked¶
Set ctl = Application.CommandBars.ActionControl¶
'Determine the file type, based on the extension¶
filetype = GetFileType(ctl.Caption)¶
filename = ctl.Tag & ctl.Caption¶
'Depending on the file type, perform an action¶
Select Case filetype¶
Case "Word"¶
'Word and text files are opened¶
Documents.Open ctl.Tag & ctl.Caption¶
Case "Excel"¶
'Excel files are inserted as Excel¶
'spreadsheet objects¶
ActiveDocument.InlineShapes.AddOLEObject _¶
ClassType:="Excel.Sheet.8", _¶
filename:=filename, _¶
Case "Powerpoint"¶
'Powerpoint files are inserted as¶
'presentation objects¶
ActiveDocument.InlineShapes.AddOLEObject _¶
ClassType:="PowerPoint.Show.8", _¶
filename:=filename, _¶
Case "Graphic"¶
'Graphics are inserted as embedded pictures¶
ActiveDocument.InlineShapes.AddPicture _¶
filename:=filename, _¶
Case "unknown"¶
Case Else¶
End Select¶
End Sub¶
Search JabSto ::

Custom Search