Custom Toolbar problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a custom toolbar which uses the "Office Links" builtin commandbutton.
I need to detect when the button has been clicked on and I can find no way of
doing this. Is it possible? Any ideas
 
BS said:
I have a custom toolbar which uses the "Office Links" builtin
commandbutton. I need to detect when the button has been clicked on
and I can find no way of doing this. Is it possible? Any ideas

Build your own function for exporting in the various formats and then
replace the Office Links button with one that calls your routine instead. I
don't think you can capture the built in feature's use.
 
BS:

I don't know all of your specifics, however, have you tried using the On
Action property for each of the options under the Office Links command
button? By right clicking one of these options when in Customize mode, you
can select Properties. On the Properties form there is an On Action setting
where you can specify the name of a macro or Visual Basic function to
execute when it is clicked.

The On Action property preempts the normal operation of the command button,
so it is necessary to call the underlying Word or Excel operation in the
custom function or macro you specified in the On Action property. The Word
Mail Merge option is equivalent to using the RunCommand method with the
acCmdWordMailMerge parameter. The Publish and Analyze options are the
equivalent of the OutputTo method with their respective parameters.

Below I have shown some sample procedures that you could use in the On
Action property for each of the three Office Links options.

Function WordMerge()

If Application.CurrentObjectType = acTable Or
Application.CurrentObjectType = acQuery Then
Debug.Print "Hello World!"
DoCmd.RunCommand acCmdWordMailMerge
Else
MsgBox "Word Mail Merge is not available for this object type.",
vbInformation, "Word Mail Merge"
End If

End Function

Function WordPublish()
Debug.Print "Hello Galaxy!"
DoCmd.OutputTo Application.CurrentObjectType,
Application.CurrentObjectName, acFormatRTF, Application.CurrentObjectName &
".rtf", True

End Function

Function ExcelAnalyze()
Debug.Print "Hello Universe!"
DoCmd.OutputTo Application.CurrentObjectType,
Application.CurrentObjectName, acFormatXLS, Application.CurrentObjectName &
".xls", True

End Function

The CurrentObjectType property maps to the acOutputObjectType enumeration
for the OutputTo method. One caveat of using this approach relates to the
Word Mail Merge option. I believe this is only available for Tables and
Queries. When the On Action property is set, the Word Mail Merge menu item
is not disabled for object types other than Tables or Queries. Therefore,
you will need to take this into account in your function in order to prevent
an error (see WordMerge procedure above). I tested this for Tables,
Queries, Forms, and Reports. If you need to support other object types, you
will have to test these functions accordingly.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


I have a custom toolbar which uses the "Office Links" builtin commandbutton.
I need to detect when the button has been clicked on and I can find no way
of
doing this. Is it possible? Any ideas
 

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

Back
Top