title: Save and Cancel buttons in Save As dialog box
body: <p>I'm creating a macro to:</p>
  
  <ol>
  <li>Ask for a "work order" number and the file to work on (OK)</li>
  <li>Insert the work order number and the file text in the new doc (OK)</li>
  <li><strong>Save the new created file in a new location and undo the changes made if the Cancel button is clicked (KO)</strong></li>
  </ol>
  
  <p>My problem is when I click the "Save" button, nothing happens. The dialog box disappears but the file is not saved, the fields are not updated and the form doesn't unload (last lines). How do I deal with these buttons? </p>
  
  <p>Here's what I did so far:</p>
  
  <pre><code>Private Sub btn_generate_Click()
      Dim dlgSave As FileDialog
      Set dlgSave = Application.FileDialog(FileDialogType:=msoFileDialogSaveAs)
      Dim oRegex As New regexp
      oRegex.Pattern = "^[0-9]+$"
  
  'Check if WO is only digits
  If (oRegex.Test(txt_wo) = False) Xor (txt_wo.TextLength &lt;&gt; 6) Then
      'Alert message
      MsgBox "The WO must be 6 digits!", vbExclamation, "Error in WO number"
      'Focus on the WO textbox + selection of the content
      txt_wo.SetFocus
      txt_wo.SelStart = 0
      txt_wo.SelLength = Len(txt_wo.Text)
  
  'Check if path to file is filled
  ElseIf txt_filePath.Text = "" Then
      'Alert message
      MsgBox "You must choose a document to reference", vbExclamation, "Missing document"
      'Focus on the "Browse"button
      btn_browse.SetFocus
  Else
  
  'Put WO after the bookmark "workorder"
  ActiveDocument.Bookmarks("workorder").Range.InsertAfter (" " + txt_wo.Text)
  
  'Copy text of the chosen file after the bookmark "texttoref"
  ActiveDocument.Bookmarks("texttoref").Range.Select
  Selection.InsertFile (txt_filePath)
  
  'Open "Save as..." dialog box
  With dlgSave
      .InitialFileName = "eRef" + txt_wo.Text + ".docx"
  
      'If the user clicks "Save"
      If .Show = False Then
          ActiveDocument.Undo 2
      End If
  End With
  
  Unload Form_CreateSheet
  ActiveDocument.Sections(1).Headers(1).Range.Fields.Update
  End If
  End Sub 
  </code></pre>