Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing formfield to Email Sub

Status
Not open for further replies.

vajpowb

Technical User
Jan 18, 2008
16
US
I need (want) to pass form field value from form to email action so user can enter an email address and send the document. Tried...and tried..not working..compile errors.

Private Sub CommandButton1_Click()
strSubject As String
strSendTo As String
strCCTo As String
strSubject = ActiveDocument.FormFields("Subject").Result
strSendTo = ActiveDocument.FormFields("SendTo").Result
strCCTo = ActiveDocument.FormFields("CCTo").Result
ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
.Subject (strSubject)
.AddRecipient (strSendTo)
.AddRecipient (strCCTo)
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route


End Sub
 
The whole message is:

"Compile error:

Statement invalid outside Type block"

1. When mentioning errors, it is always helpful to actually state the full text of the error message.

2. is there a Debug highlighting? Probably. It probably highlights:
Code:
Private Sub CommandButton1_Click()
[highlight]strSubject As String[/highlight]

It requires a Dim!

Dim strSubject As String

You can use strSubject As String but only....as the error states...within a Type block. Outside a Type block, it is....Invalid. Just like the error states.

3. Please use the code tags when posting code. Thanks.



faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top