S
Summer
Hello,
I've a dynamic menu on ribbon Word 2007 and it pulls .dot .dotx. dotm - this
however does now include subfolders or their contents in the WorkGroup Path
folder.
I'd like to create new dynamicmenu Code to read the same WorkGroups path but
select specific SubFolder's Contents? I'm not sure how to approach setting a
specific path to specific subfolder and its contents.
I'm at the dog paddle stage with this - so drowning is imminent! THANK YOU.
Sub rxdmnuTemplates_GetContent(control As IRibbonControl, ByRef content)
'Callback for GetContent to return XML used to create dynamicMenu
Dim objFSO As Object
Dim objTemplateFolder As Object
Dim file As Object
Dim sXML As String
Dim lBtnCount As Long
'Open the XML string
sXML = "<menu xmlns=""" & _
"http://schemas.microsoft.com/office/2006/01/customui"">"
'Create FSO object and set to templates folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTemplateFolder = _
objFSO.getfolder(Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath))
'Add template files
If objTemplateFolder.Files.Count > 0 Then
For Each file In objTemplateFolder.Files
'Check if file is a temporary file
If Not Left(file.Name, 2) = "~$" Then
'File is not a temp file, so check extension
Select Case LCase(Right(file.Name, 4))
Case ".dot", "dotx", "dotm"
'Word template.
If Not LCase(Left(file.Name, 6)) = "normal" Then
sXML = sXML & _
"<button id=""rxbtnDyna" & _
lBtnCount & """ " & _
"label=""" & file.Name & """ " & _
"imageMso=""FileSaveAsWord97_2003"" " & _
"tag=""" & file.Path & """ " & _
"onAction=""rxbtnDyna_onAction""/>" &
vbCrLf
lBtnCount = lBtnCount + 1
End If
Case Else
'Unknown format. Ignore.
End Select
End If
Next file
End If
'Release the FSO objects
Set file = Nothing
Set objTemplateFolder = Nothing
Set objFSO = Nothing
'Check if any items buttons were created
'Create a "No Templates" button if not
If lBtnCount = 0 Then _
sXML = sXML & "<button id=""rxbtnDyna0"" label=""No Templates
Found""/>"
'Add Refresh button & close the menu tags
sXML = sXML & _
"<button id=""rxbtnRefresh"" " & _
"label=""Refresh List"" " & _
"imageMso=""RecurrenceEdit"" " & _
"onAction=""rxbtnDyna_onAction""/>" & _
"</menu>"
'Feed the XML back to the Ribbon
content = sXML
End Sub
I've a dynamic menu on ribbon Word 2007 and it pulls .dot .dotx. dotm - this
however does now include subfolders or their contents in the WorkGroup Path
folder.
I'd like to create new dynamicmenu Code to read the same WorkGroups path but
select specific SubFolder's Contents? I'm not sure how to approach setting a
specific path to specific subfolder and its contents.
I'm at the dog paddle stage with this - so drowning is imminent! THANK YOU.
Sub rxdmnuTemplates_GetContent(control As IRibbonControl, ByRef content)
'Callback for GetContent to return XML used to create dynamicMenu
Dim objFSO As Object
Dim objTemplateFolder As Object
Dim file As Object
Dim sXML As String
Dim lBtnCount As Long
'Open the XML string
sXML = "<menu xmlns=""" & _
"http://schemas.microsoft.com/office/2006/01/customui"">"
'Create FSO object and set to templates folder
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTemplateFolder = _
objFSO.getfolder(Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath))
'Add template files
If objTemplateFolder.Files.Count > 0 Then
For Each file In objTemplateFolder.Files
'Check if file is a temporary file
If Not Left(file.Name, 2) = "~$" Then
'File is not a temp file, so check extension
Select Case LCase(Right(file.Name, 4))
Case ".dot", "dotx", "dotm"
'Word template.
If Not LCase(Left(file.Name, 6)) = "normal" Then
sXML = sXML & _
"<button id=""rxbtnDyna" & _
lBtnCount & """ " & _
"label=""" & file.Name & """ " & _
"imageMso=""FileSaveAsWord97_2003"" " & _
"tag=""" & file.Path & """ " & _
"onAction=""rxbtnDyna_onAction""/>" &
vbCrLf
lBtnCount = lBtnCount + 1
End If
Case Else
'Unknown format. Ignore.
End Select
End If
Next file
End If
'Release the FSO objects
Set file = Nothing
Set objTemplateFolder = Nothing
Set objFSO = Nothing
'Check if any items buttons were created
'Create a "No Templates" button if not
If lBtnCount = 0 Then _
sXML = sXML & "<button id=""rxbtnDyna0"" label=""No Templates
Found""/>"
'Add Refresh button & close the menu tags
sXML = sXML & _
"<button id=""rxbtnRefresh"" " & _
"label=""Refresh List"" " & _
"imageMso=""RecurrenceEdit"" " & _
"onAction=""rxbtnDyna_onAction""/>" & _
"</menu>"
'Feed the XML back to the Ribbon
content = sXML
End Sub