title: How to: attach .pdf and send email with no user input needed
body: <p>I've edited my question based on the feedback. I have a form that I want users to be able to silently (no user input required) save and send with one button click. </p>
  
  <p>The following code is saving as a .pdf with the correct name in the same document/path as the original file (which I want). However when the email is sent, the attachment is the original .docm file instead.</p>
  
  <p>The final attachment must be a .pdf as it will be emailed to a Microsoft Team site and macro-enabled files will not work on Teams. </p>
  
  <p>I'm new to VBA beyond basic commands for my own workflow. I'm working my way through various tutorials/courses and an extremely large book on vba for Office but I would appreciate a fix my newbie coding error sooner rather than later. </p>
  
  <pre><code>Private Sub btnSubmit_Click()
  
  strName = ActiveDocument.SelectContentControlsByTitle("ddName")(1).Range.Text
  strDate = ActiveDocument.SelectContentControlsByTitle("ddDate")(1).Range.Text
  strTest = ActiveDocument.SelectContentControlsByTitle("ddTestNumber")(1).Range.Text
  
  Dim strFilename As String
  strFilename = strName &amp; "_" &amp; "VBATestFile_" &amp; strTest &amp; "_" &amp; Format(strDate, "yyyymmdd") &amp; ".pdf"
  
  ActiveDocument.SaveAs2 strFilename, FileFormat:=wdFormatPDF
  
  Dim OL          As Object
  Dim EmailItem   As Object
  Dim Doc         As Document
  
  Application.ScreenUpdating = False
  Set OL = CreateObject("Outlook.Application")
  Set EmailItem = OL.CreateItem(olMailItem)
  Set Doc = ActiveDocument
  Doc.Save
  
  With EmailItem
      .Subject = strName &amp; " Test" &amp; strTest
      .Body = "Test email send for " &amp; strName &amp; " " &amp; strTest &amp; "."
      .To = "email address here"
      .Importance = olImportanceNormal
      .Attachments.Add Doc.FullName
      .Send
  End With
  
  Application.ScreenUpdating = True
  
  MsgBox "Form Submitted", vbInformation
  
  Set Doc = Nothing
  Set OL = Nothing
  Set EmailItem = Nothing
  
  End Sub
  </code></pre>