Difference between MacroButton field and CommandButton

S

ssr

Hi,
Being very new, I am interested in when you might use one of these over
the other.

I have a macro written in VBA editor called MoveData that opens another
document and passes values from the first docuemnt into it. The macro
works well.

I need to put a button on the first document for a user to invoke the
MoveData procedure when he is ready.

I added a command button and subroutine to it and it works well until I
put it into a SharePoint document library. Then when you click it the
right panel in Word 2003 closes and it takes another click to start the
macro.

If I Insert a MacroButton field, I don't know how to get a button shape
around it and the text appears in quotes. The field looks like
{MACROBUTTON MoveData "Apply Now"}.

I am wondering if it would behave differently when clicking on it. Can
you please tell me how to get a shape around it and any code that might
be required in addition to the field code above?

Thank you.
 
J

Jay Freedman

Hi,
Being very new, I am interested in when you might use one of these over
the other.

I have a macro written in VBA editor called MoveData that opens another
document and passes values from the first docuemnt into it. The macro
works well.

I need to put a button on the first document for a user to invoke the
MoveData procedure when he is ready.

I added a command button and subroutine to it and it works well until I
put it into a SharePoint document library. Then when you click it the
right panel in Word 2003 closes and it takes another click to start the
macro.

If I Insert a MacroButton field, I don't know how to get a button shape
around it and the text appears in quotes. The field looks like
{MACROBUTTON MoveData "Apply Now"}.

I am wondering if it would behave differently when clicking on it. Can
you please tell me how to get a shape around it and any code that might
be required in addition to the field code above?

Thank you.

I don't use SharePoint, so I can't tell you what the problem is with
the command button there. I suspect it has something to do with the
fact that it's an ActiveX control hosted in the document. You can read
up on it here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnword2k2/html/odc_activeX.asp

For the macrobutton field, a few hints:

- You don't need the quote marks inside the field code. Remove them so
they won't show when the field is collapsed.

- One (ugly) way to make it look like a button is to select the words
Apply Now inside the field code, go to Format > Borders & Shading, and
apply a shadow border (note that the Apply To box should say Text).
The border will still appear when the field is collapsed.

- A better way is to steal the appearance of the command button... Use
Alt+PrintScrn to take a screen shot of the page that has the command
button. Paste that into Paint and crop down to just the button; save
the result as a .jpg file. In the macrobutton code, replace the words
Apply Now with the picture (using Insert > Picture > From File).

- If you have an AutoOpen routine containing the line

Options.ButtonFieldClicks = 1

then users can single-click instead of double-click to activate the
macro. No other code (besides the MoveData routine itself) is
required.

More info at
http://www.word.mvps.org/FAQs/TblsFldsFms/UsingMacroButton.htm.
 

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