Change the numeric value of a dropdown to text value

W

Worsty

I'm trying to email the values of form fields that I have created in a
form. So basically what I want to do is in the Subject I want to take
the "value" of the dropdown called dropdown1 and put it in the
subject. It is working but it is putting the numeric value instead of
the text value. How do I convert it.

Thanks much!
 
D

Doug Robbins - Word MVP

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
 
W

Worsty

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
 
D

Doug Robbins - Word MVP

.Subject = ActiveDocument.FormFields("Dropdown4").DropDown.Result

should be

.Subject = ActiveDocument.FormFields("Dropdown4").Result

--
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
 
W

Worsty

 .Subject = ActiveDocument.FormFields("Dropdown4").DropDown.Result

should be

 .Subject = ActiveDocument.FormFields("Dropdown4").Result

--
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


*****************************************

Thanks Doug....I did make that change and it worked great! Should
have seen that myself.

I have another question about that code.

How do I populate the .TO field of the Outlook message based on the
value of a dropdown field. So far I have the following:

If (ActiveDocument.FormFields("CA7Forms").DropDown.Value = 2) Then
.To = "(e-mail address removed)"
Else
.To = "(e-mail address removed)"

That doesn't work. It always gives me the same email address.

Thanks for your help....again!

Debbie
 
W

Worsty

*****************************************

Thanks Doug....I did make that change and it worked great!  Should
have seen that myself.

I have another question about that code.

How do I populate the .TO field of the Outlook message based on the
value of a dropdown field.  So far I have the following:

If (ActiveDocument.FormFields("CA7Forms").DropDown.Value = 2) Then
     .To = "(e-mail address removed)"
     Else
     .To = "(e-mail address removed)"

That doesn't work.  It always gives me the same email address.

Thanks for your help....again!

Debbie- Hide quoted text -

- Show quoted text -

Could anyone please give me some direction on this request. I have
been trying unsuccessfully to get this to look at the value of the
dropdown and if 1 send to this email address and if 2 send to this
email address.

Thanks so much!
 
D

Doug Robbins - Word MVP

The .DropDown.Value of a DropDown formfield will return the position of the
selected item in the list of items - 1 for the first item, 2, for the second
and so on.

Is the number 2 that you are using in your code one of the items in the list
or are you wanting to check if the second item in the list is selected?

If 2 is an item in the list, you should use the .Result property of the
DropDown, not the .DropDown.Value.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

*****************************************

Thanks Doug....I did make that change and it worked great! Should
have seen that myself.

I have another question about that code.

How do I populate the .TO field of the Outlook message based on the
value of a dropdown field. So far I have the following:

If (ActiveDocument.FormFields("CA7Forms").DropDown.Value = 2) Then
.To = "(e-mail address removed)"
Else
.To = "(e-mail address removed)"

That doesn't work. It always gives me the same email address.

Thanks for your help....again!

Debbie- Hide quoted text -

- Show quoted text -

Could anyone please give me some direction on this request. I have
been trying unsuccessfully to get this to look at the value of the
dropdown and if 1 send to this email address and if 2 send to this
email address.

Thanks so much!
 
W

Worsty

The .DropDown.Value of a DropDown formfield will return the position of the
selected item in the list of items - 1 for the first item, 2, for the second
and so on.

Is the number 2 that you are using in your code one of the items in the list
or are you wanting to check if the second item in the list is selected?

If 2 is an item in the list, you should use the .Result property of the
DropDown, not the .DropDown.Value.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my serviceson
a paid professional basis.











Could anyone please give me some direction on this request.  I have
been trying unsuccessfully to get this to look at the value of the
dropdown and if 1 send to this email address and if 2 send to this
email address.

Thanks so much!- Hide quoted text -

- Show quoted text -

Doug:
Thanks, that worked! I really appreciate your help.

Debbie
 

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