Add command button to Word document to send as email

K

Kurt Heisler

This question has been asked many times, but I can’t seem to find a
solution that works. Not sure what I’m doing wrong.

I would like to add a “Submit” button on a protected Word 2003
document, so when the user clicks on it his Outlook 2003 opens and
sends the document to me as an attachment. I tried to do this but when
I click on the button, the button depresses but nothing else happens
(the code doesn’t run). Also, if I close the document and reopen it,
it’s still protected but is back in Design View (even though the
Design View button on the Control Toolbox is grayed out).
Consequently, the button doesn’t work, and the user can access its
properties and VB code.

Here's what I did. I'm obviously overlooking something:

1. Unprotect form.
2. Add command button (using the Command Button on the Control
Toolbox)
3. Add the code to the command button (double click on Command Button,
add code in VB window)
4. Save and close the VB window
5. Exit out of Design mode (click the Design Mode button on the
Control Toolbox)
6. Protect and Save form.

I suspect the problem has nothing to do with the VB code ("Hello
world" probably wouldn't even work) and everything to do with how I’m
adding the command button. But, here is the code I’m using:

ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
.Subject = "Subject line goes here"
.AddRecipient "(e-mail address removed)"
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route
 
D

Doug Robbins - Word MVP

The problem with trying to do this sort of thing is that it relies on the
user having his macro security settings set so that he is asked if he wants
to enable or disable the macros in the document AND on him allowing them to
be enabled.

You are probably better off just asking them to email the document back to
you.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
This question has been asked many times, but I can’t seem to find a
solution that works. Not sure what I’m doing wrong.

I would like to add a “Submit” button on a protected Word 2003
document, so when the user clicks on it his Outlook 2003 opens and
sends the document to me as an attachment. I tried to do this but when
I click on the button, the button depresses but nothing else happens
(the code doesn’t run). Also, if I close the document and reopen it,
it’s still protected but is back in Design View (even though the
Design View button on the Control Toolbox is grayed out).
Consequently, the button doesn’t work, and the user can access its
properties and VB code.

Here's what I did. I'm obviously overlooking something:

1. Unprotect form.
2. Add command button (using the Command Button on the Control
Toolbox)
3. Add the code to the command button (double click on Command Button,
add code in VB window)
4. Save and close the VB window
5. Exit out of Design mode (click the Design Mode button on the
Control Toolbox)
6. Protect and Save form.

I suspect the problem has nothing to do with the VB code ("Hello
world" probably wouldn't even work) and everything to do with how I’m
adding the command button. But, here is the code I’m using:

ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
.Subject = "Subject line goes here"
.AddRecipient "(e-mail address removed)"
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route
 
K

Kurt Heisler

The users have digital certificates in place so the macro security
problem has been addressed.
 
J

Jay Freedman

I'd suggest using a MacroButton field
(http://www.word.mvps.org/FAQs/TblsFldsFms/UsingMacroButton.htm)
instead of an ActiveX command button. Move the code to a macro in a
regular module (not the ThisDocument module) and put the name of that
macro in the MacroButton field.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
E

eugenedf

Jay said:
I'd suggest using a MacroButton field
('Using MacroButton fields'
(http://www.word.mvps.org/FAQs/TblsFldsFms/UsingMacroButton.htm))
instead of an ActiveX command button. Move the code to a macro in a
regular module (not the ThisDocument module) and put the name of that
macro in the MacroButton field.

MacroButton Field does work for me. But I have created check boxes
using the Form toolbar, and as soon as I lock, I can no longer double
click and execute my macro.

Also - can anyone suggest how I can record the macro in order for the
user to have NO involvement whatsoever? I mean he-she must just click
the button, and it should automatically add the document as attachment,
fill in the recipients, and send as well.

Any help would be appreciated.
 

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