Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add command button to Word document to send as email

5,058 views
Skip to first unread message

Kurt Heisler

unread,
Oct 14, 2009, 11:13:19 AM10/14/09
to
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 "blah...@gmail.com"
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route

Doug Robbins - Word MVP

unread,
Oct 14, 2009, 3:36:46 PM10/14/09
to

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
"Kurt Heisler" <heisl...@gmail.com> wrote in message
news:b251efb0-96bc-4bb2...@l34g2000vba.googlegroups.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:

Kurt Heisler

unread,
Oct 14, 2009, 6:41:36 PM10/14/09
to
The users have digital certificates in place so the macro security
problem has been addressed.

On Oct 14, 3:36 pm, "Doug Robbins - Word MVP"


<d...@REMOVECAPSmvps.org> wrote:
> 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"Kurt Heisler" <heislerk...@gmail.com> wrote in message
>
> news:b251efb0-96bc-4bb2...@l34g2000vba.googlegroups.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 "blahb...@gmail.com"

Jay Freedman

unread,
Oct 14, 2009, 8:06:32 PM10/14/09
to
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 FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

eugenedf

unread,
Oct 28, 2009, 8:02:29 AM10/28/09
to

Jay Freedman;525431 Wrote:
> 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.


--
eugenedf
------------------------------------------------------------------------
eugenedf's Profile: http://www.thecodecage.com/forumz/member.php?userid=1100
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=144078

lulalot...@gmail.com

unread,
Nov 27, 2018, 11:22:11 PM11/27/18
to
0 new messages