Microsoft Office Tutorials and References
In Depth Information
Creating a Folder Tree Menu
'Go to the next entry¶
folderContent = Dir¶
Loop¶
GetMenuEntries = aEntries()¶
End Function¶
' * * * * *¶
Function CreateNewPopup( _¶
cb As CommandBar, _¶
s As String, _¶
Pos As Long) As Office.CommandBarPopup¶
'Variable declaration¶
Dim ctl As Office.CommandBarPopup¶
'If 0 is passed in, then the entry should appear¶
'at the end of the list¶
If Pos = 0 Then¶
Set ctl = cb.Controls.Add(Type:=msoControlPopup)¶
Else¶
'Otherwise, place it at the top¶
Set ctl = cb.Controls.Add(Type:=msoControlPopup, Before:=Pos)¶
End If¶
With ctl¶
'The folder name is the caption¶
.Caption = s¶
.Enabled = True¶
.Visible = True¶
End With¶
Set CreateNewPopup = ctl¶
End Function¶
' * * * * *¶
Function CreateMenuButton( _¶
cb As CommandBar, _¶
filename As String, _¶
path As String)¶
'Variable declaration¶
Dim ctl As Office.CommandBarButton¶
Dim filetype As String¶
'Determine what kind of file by the extension¶
filetype = GetFileType(path & filename)¶
'Don't include unwanted file types¶
'to deal with¶
If filetype = "unknown" Then Exit Function¶
'Create the new button¶
Set ctl = cb.Controls.Add(Type:=msoControlButton)¶
With ctl¶
.Caption = filename¶
.Enabled = True¶
.Visible = True¶
'The macro to run when the button is clicked¶
'in this case, all buttons run the same macro¶
.OnAction = "ProcessFile"¶
Wrd
Search JabSto ::




Custom Search