![]() |
#1
|
|||
|
|||
![]()
I have a Word form for users to fill save and mail as an attachment. I have a drop down field to select the Display Name (company name) and it has a corresponding Value (Company Code). When I click submit it save the file with the name of a date field, Company Name and User Name. I need to use the Value of selected drop down (Company Code) instead of Display Name (Company Name).
Public Sub commandbutton1_click() Dim OL As Object Dim EmailItem As Object Dim Doc As Document Dim strFN As String Dim strLN As String Dim strSD As String Dim strBU As String Dim myDateStamp As String Dim strPath As String Dim strFilename As String strPath = Environ("USERPROFILE") strFN = ActiveDocument.SelectContentControlsByTitle("FName ")(1).Range.Text strLN = ActiveDocument.SelectContentControlsByTitle("LName ")(1).Range.Text strSD = ActiveDocument.SelectContentControlsByTitle("SDate ")(1).Range.Text strBU = ActiveDocument.SelectContentControlsByTitle("CName ")(1).Range.Text strFilename = strFN & "-" & strLN myDateStamp = Format(Date, "yyyymmdd") FilePath = strPath & "\Documents\" & myDateStamp & "-ONB-" & strFilename & ".docm" ActiveDocument.SaveAs (FilePath) Application.ScreenUpdating = False Set OL = CreateObject("Outlook.Application") Set EmailItem = OL.CreateItem(olMailItem) Set Doc = ActiveDocument Doc.Save With EmailItem .Subject = "[ONB-" & strBU & "]: " & strFN & " " & strLN & " - " & strSD .Body = "" & vbCrLf & _ "" & vbCrLf & _ "" .To = "itsupport@abc.com" .Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow .Attachments.Add Doc.FullName .Display MsgBox " ****** Thanks for Submitting the On-Boarding Form ****** " End With Application.ScreenUpdating = True Set Doc = Nothing Set OL = Nothing Set EmailItem = Nothing End Sub |
#2
|
|||
|
|||
![]()
I know of no way, in VBA, to reach the "value."
That may simply display my ignorance (which is vast). I would code in a test for the text and use that to determine the abbreviation to be used. This could be in a separate and hidden content control rather than in the vba. See Linked Content Control Drop-Down List. |
![]() |
Tags |
document saveas, drop down list value, drop down lists |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ahw | Word VBA | 43 | 02-28-2020 08:11 PM |
Drop down list | emukiss10 | Word VBA | 0 | 11-20-2017 02:18 AM |
![]() |
celias | Word VBA | 3 | 07-11-2016 11:40 PM |
![]() |
brmveen | Word VBA | 2 | 11-04-2015 12:51 AM |
Drop down list, Can it be done??? | garethreid | Outlook | 0 | 08-09-2012 06:08 AM |