Use the .Result, not the .Value
--
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
- Show quoted text -
Thanks Doug, but when I put .Result in my code it gives me this error.
Method or data member not defined error. I also put some additional
code case statement (below) and then it didn't work at all.
Here is what I have so far.
Public Sub CommandButton1_Click()
'This macro requires the Outlook Object library to be checked
'in the vba editor Tools > References
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
If Len(ActiveDocument.Path) = 0 Then 'Document has not been saved
ActiveDocument.Save 'so save it
End If
'see if Outlook is running and if so turn your attention there
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then 'Outlook isn't running
'So fire it up
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Open a new e-mail message
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem 'and add the detail to it
.To = "(e-mail address removed)" 'send to this address
.Subject = ActiveDocument.FormFields("Dropdown4").DropDown.Result
'This is the message subject
.Body = "See attached document" ' This is the message body text
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue
.Display
'**********************************
'If you want to view the message before it goes
'change the line above from .Send to .Display
'Otherwise the message is sent straight to the Outbox
'and if you have Outlook set to send mail immediately,
'it will simply be Sent
'with no obvious sign that Outlook has operated.
'Apart from the copy in the Outlook Sent folder
'**********************************
End With
If bStarted Then 'If the macro started Outlook, stop it again.
oOutlookApp.Quit
End If
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
*****************************************************************************************************
I tried to put the following code at the top of my Email code but then
I got nothing.
Any help would be appreciated.
Dim myString As String
Select Case _
ActiveDocument.FormFields("Dropdown3").DropDown.Value
Case 2
myString = "Two"
Case 3
myString = "three"
MsgBox ("I got here")
End Select
'ActiveDocument.FormFields("Text31").Result = myString
On Error Resume Next