Word 2000 menu and passing a parameters to macro, please

M

Mike

Hi ! I am programmatically creating a menu in Word 2000 to display Recent
Drafts and Recent Submissions. The requirements specify that upon selecting
Recent from the pulldown menu, the menu should expand to the right displaying
10 recent documents.
So far, I am able to do that. The problem is when I click on one of the
documents listed, I need to call a function called OpenDoc().

My question is: How do I pass the name of the document to this
function/macro ?

Here’s how I build the menu:

Private Sub BuildMenuItem(ByRef pobjCommandBarControls As
Office.CommandBarControls, _
ByRef pobjCommanBarControl As
Office.CommandBarControl, _
ByVal pobjMenuType As Office.MsoControlType, _
ByVal pstrMenuCaption As String, _
ByVal pstrMenuAction As String, _
ByVal pblnCreateDivider As Boolean)

On Error GoTo ErrHandler

With pobjCommandBarControls

Set pobjCommanBarControl = .Add(pobjMenuType)
pobjCommanBarControl.Caption = pstrMenuCaption
If pstrMenuAction <> "" Then
pobjCommanBarControl.OnAction = pstrMenuAction
End If

pobjCommanBarControl.BeginGroup = pblnCreateDivider

' pobjCommanBarControl.Parameter = ??? – How do I use it ?
End With
Exit Sub

ErrHandler:
MsgBox Err.Description
End Sub


Many Thanks in Advance,

--Mike
 
J

Jezebel

You can set the parameter to anything you like, such as the file name, or
the index of the filename if you are maintaining a separate array of names.
There's also the Tag property, if you need a second argument.
 
J

Jezebel

In your DocOpen() function you use

CommandBars.ActionControl to get a reference to the whatever was clicked
to call this macro. So if you've put the filename into the control's
Parameter property, you'd use something like

Documents.Open FileName:=CommandBars.ActionControl.Parameter
 
M

Mike

That's it ! Thank you very much!

Any good book/URL you can recommend to learn this stuff ?

Many Thanks for your help,

-- Mike Z...
 

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

Top