Why doesn't Word show dropdown box results in form when emailed?

S

Stella

I have designed a form for salespeople which is simple to use and want them
to be able to click on 'SEND TO' (via Outlook) from Word (2003)so that they
can send the results from there rather than attaching as a Word document.
However, if they do this the answers they've selected in the drop down boxes
do not show. If they attach as a Word doc it is perfect. Would be grateful
if anyone knows why or how to fix..
 
G

Graham Mayor

The formatting requirements of HTML e-mail and word document are different;
however if it is only the results of the form fields that you are interested
in, it is simple enough to e-mail those in the form of (say) a comma
delimited file. The following macro will extract the content of each field
(check boxes copy as 0 or 1) and write it into a throw away Word document as
a comma delimited file. When all the fields are extracted, the macro then
e-mails the resulting comma delimited file to the e-mail address indicated.

You will need to add the Microsoft Outlook Object Library to vba Tools >
References for this to work.

I have set the macro to display the message. If you want to simply send it,
change the line .Display to .Send

Sub ExtractData()
Dim oFld As FormFields
Dim sText As String
Dim i As Long
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim dDataDoc As Word.Document
Dim dSource As Word.Document
Dim objDoc As Word.Document
Set dSource = ActiveDocument
Set dDataDoc = Documents.Add
Set oFld = dSource.FormFields
Application.ScreenUpdating = False
For i = 1 To oFld.Count
sText = oFld(i).Result
dDataDoc.Activate
If i <> 1 Then Selection.TypeText ","
Selection.TypeText sText
If i = oFld.Count Then Selection.TypeParagraph
dSource.Activate
Next i
dDataDoc.Range.Copy

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")

'Outlook wasn't running, start it from code
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
Set objDoc = oItem.GetInspector.WordEditor
With oItem
.To = "(e-mail address removed)"
.Subject = "Data Return"
objDoc.Range.Paste
.Display
End With

'Clean up
Application.ScreenUpdating = True
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub

http://www.gmayor.com/installing_macro.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