Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-2018, 10:29 PM
niho niho is offline use a Drop-down List Value to determine the file name to save Windows 10 use a Drop-down List Value to determine the file name to save Office 2016
Novice
use a Drop-down List Value to determine the file name to save
 
Join Date: Feb 2018
Posts: 1
niho is on a distinguished road
Default use a Drop-down List Value to determine the file name to save

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
Attached Images
File Type: png ScreenCapture.PNG (5.5 KB, 16 views)
Attached Files
File Type: docm ONB-TEST-Form-I.docm (51.9 KB, 10 views)
Reply With Quote
  #2  
Old 03-02-2018, 09:35 AM
Charles Kenyon Charles Kenyon is offline use a Drop-down List Value to determine the file name to save Windows 10 use a Drop-down List Value to determine the file name to save Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,471
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
Reply

Tags
document saveas, drop down list value, drop down lists



Similar Threads
Thread Thread Starter Forum Replies Last Post
use a Drop-down List Value to determine the file name to save How to import list from Excel into drop-down list into word ahw Word VBA 43 02-28-2020 08:11 PM
Drop down list emukiss10 Word VBA 0 11-20-2017 02:18 AM
use a Drop-down List Value to determine the file name to save Having a Drop-down list in Word referring to an Excel list celias Word VBA 3 07-11-2016 11:40 PM
use a Drop-down List Value to determine the file name to save save dialog box promt doesn't save file 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

Other Forums: Access Forums

All times are GMT -7. The time now is 09:11 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft