MS Word Forms

Microsoft Word 2000
July 2, 2010 at 13:02:34
Specs: Windows XP
I have set up a form as a protected template.
When the recipient has filled in the text and drop-down fields, there is a check box field which says that they confirm their answers.
When they click on this box, I want the completed form to be returned to me as an attachment.
I have tried setting up a macro that routes it back to me, but it doesn't work.
Any help will be gratefully received.

See More: MS Word Forms

Report •

July 2, 2010 at 16:12:36

I don't know enough about your template, and how the completed form is used, saved etc. to be able to test this out properly.

But the following may give you something to work with.
I added a check box to a Word document and used the CheckBox Click event to trigger the macro.
If the check box was checked (Value=True), then the rest of the code runs.
It sends an html attachment (it can send other types) but I have found in my limited use of this that html works!

So save a copy of the form as in html file format and use that as the email attachment.
Using html format means that the check box and associated VBA code is not sent.

One problem with this method is that if your outgoing mail server requires authentication, you need a password - which is in plain text.

If you do go down this route, then apart from protecting the code and the form, you may want to set up an email account that is only used for this purpose, so that anyone gaining access to the password cannot access a regular email account.

Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
    Dim strFilename As String
    Dim objMail As Object
    On Error GoTo ErrHnd:

    'copy the current path and filename
    strOrigFileName = Me.Path & "\" & Me.Name
    'set the temp filename and path
    strFileSave = "C:\Temp\EMailTemp.html"
    'save a copy as a temporary file
    Me.SaveAs FileName:=strFileSave, Fileformat:=wdFormatHTML
    're-save as original file, so as to release temp file
    Me.SaveAs FileName:=strOrigFileName, Fileformat:=wdFormatDocument
    'create the e-mail object
    Set objEmail = CreateObject("CDO.Message")
    With objEmail
        With .Configuration.Fields
           .Item( _
           "") _
                = ""
           .Item( _
           "") _
                = "30"
           .Item( _
           "") _
                = "2"
           .Item( _
           "") _
                = "25"
           .Item( _
           "") _
                = ""
           .Item( _
           "") _
                = "1"
           .Item( _
           "") _
                = ""
           .Item( _
           "") _
                = "ZZZZZZZZZZ"
        End With
        'create e-mail message
        .To = ""
        .From = ""
        .Subject = "Completed form"
        .AddAttachment strFileSave
        'send e-mail
    End With
    'remove the e-mail object
    Set objEmail = Nothing

End If
Exit Sub

'error handler
End Sub

Checking the check box in my test document did send the document and I was able to retrieve it from my email in box and open the attachment in my browser.


Report •
Related Solutions

Ask Question