Open save as window and populate file name and file path from cell

后端 未结 1 1890
忘掉有多难
忘掉有多难 2021-01-07 09:55

I\'m trying to open the save as window and populate the file name and file path from a cell

Here\'s the code I have which does populate the file name and opens the s

相关标签:
1条回答
  • 2021-01-07 10:44

    The file dialog doesn't actually save the file - it just prompts the user for a filename or allows the user to change a default filename. You have to get the selected filename back and save it independently something like this:

    Dim fPth As Object
    Set fPth = Application.FileDialog(msoFileDialogSaveAs)
    
    With fPth
      .InitialFileName = FileName & ".xlsm"
      .Title = "Save your File"
      .InitialView = msoFileDialogViewList
      If .Show <> 0 Then
        ThisWorkbook.SaveAs FileName:=.SelectedItems(1), FileFormat:=xlWorkbookNormal
      End If
    End With
    
    0 讨论(0)
提交回复
热议问题