Consulting

Results 1 to 2 of 2

Thread: Linking a submit button to an option from a drop-down menu

  1. #1
    VBAX Newbie
    Joined
    Jul 2019
    Posts
    1
    Location

    Linking a submit button to an option from a drop-down menu

    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

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,056
    Location
    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
    Greg

    Visit my website: http://gregmaxey.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •