S
Stephen English
I have used the code below to generate to add buttons to a
menu bar from a folder full of file names and it is
working fine.
For Each f1 In fc
With ctlCBarControl
Set ctlButton = .Controls.Add(msoControlButton)
ctlButton.Caption = f1.Name
ctlButton.OnAction = "OpenDocS"
ctlButton.Tag = f1.Name
End With
Next
I am trying to create the code in Sub OpenDocS and use
the .tag of the control as a parameter for the document to
open.
My problem is that I can't work out how to refer to the
active control when it is a menubar button.
Set ctlCBarControl = CommandBars("Menu Bar").Controls
("COS").Controls("Index Review").Controls("SubCommittees")
' The active control is one level deeper than this
SubCommittees control
Set ctlActive = ctlCBarControl.ActiveControl
If Not FileLocked(strPath & "\SubCommittees\" &
ctlActive.Tag) Then
Documents.Open FileName:=ctlActive.Tag,
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Thanks
Stephen
menu bar from a folder full of file names and it is
working fine.
For Each f1 In fc
With ctlCBarControl
Set ctlButton = .Controls.Add(msoControlButton)
ctlButton.Caption = f1.Name
ctlButton.OnAction = "OpenDocS"
ctlButton.Tag = f1.Name
End With
Next
I am trying to create the code in Sub OpenDocS and use
the .tag of the control as a parameter for the document to
open.
My problem is that I can't work out how to refer to the
active control when it is a menubar button.
Set ctlCBarControl = CommandBars("Menu Bar").Controls
("COS").Controls("Index Review").Controls("SubCommittees")
' The active control is one level deeper than this
SubCommittees control
Set ctlActive = ctlCBarControl.ActiveControl
If Not FileLocked(strPath & "\SubCommittees\" &
ctlActive.Tag) Then
Documents.Open FileName:=ctlActive.Tag,
ConfirmConversions:=False, _
ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
Thanks
Stephen