PDA

View Full Version : Linking a submit button to an option from a drop-down menu



scubasam
07-17-2019, 09:27 AM
Hello all

Here's the situation:
- I've created a form in Word
- At the bottom of the form I want a drop-down list containing several email addresses
- I also want a submit button

Here's what I want to happen:
- Someone fills out the form
- They select their manager's name from the drop-down menu
- They hit the submit button and the file gets emailed as a pdf to that particular manager

I'm totally stumped. I can't figure out how to make the submit button "link" to the drop-down menu choice(s). I'm not good at VBA or coding so please be very specific... Pretend you're teaching a 5-year-old.

Thanks for your help.

Cheers
Sam

gmaxey
07-17-2019, 02:57 PM
Sam,

Really. This is not a free macro writing service. The internet is full of examples of saving and sending files as a PDF e-mail attachment.

Here is one example:


Private Sub SaveAsPDFAndEmail()
Dim oOLApp As Object
Dim oMailItem As Object
Dim oDoc As Document
Dim strFileName As String

Application.ScreenUpdating = False
Set oOLApp = CreateObject("Outlook.Application")
Set oMailItem = oOLApp.CreateItem(0)
Set oDoc = ActiveDocument
If Not oDoc.Saved Then
MsgBox "You must first save the activeo document before submitting"
Exit Sub
End If
strFileName = Replace(oDoc.FullName, ".docm", ".pdf")
oDoc.ExportAsFixedFormat OutputFileName:=strFileName, _
ExportFormat:=wdExportFormatPDF
With oMailItem
.Subject = "***subject***"
.Body = "Here is your attachment"
.To = ActiveDocument.SelectCOntentControlByTitle("Manager Email").Item(1).Range.Text
.Importance = 1 ' olImportanceNormal
.Attachments.Add strFileName
.Send
End With
Application.ScreenUpdating = True
Set oDoc = Nothing
Set oMailItem = Nothing
Set oOLApp = Nothing
MsgBox "Email has been sent"
ActiveDocument.Close SaveChanges:=wdSaveChanges
End Sub