Onaction from Menu button

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
 
S

Stephen English

Thank you for the prompt response
Stephen English
City of Salisbury
South Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top