Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-07-2023, 04:56 AM
Franci Franci is offline Can't save file using a msoFileDialogSaveAs Windows 10 Can't save file using a msoFileDialogSaveAs Office 2016
Novice
Can't save file using a msoFileDialogSaveAs
 
Join Date: May 2016
Posts: 12
Franci is on a distinguished road
Default Can't save file using a msoFileDialogSaveAs

Hi!


I have a macro, that should show a file save as dialog and save the file:




Code:
Sub ShowSaveAsDialog()
 Dim dlgSaveAs As FileDialog
 
 Application.FileDialog(msoFileDialogSaveAs).InitialFileName = FName
 
 Set dlgSaveAs = Application.FileDialog( _
 FileDialogType:=msoFileDialogSaveAs)
 dlgSaveAs.Show
 End Sub
I call this macro when the document is closed. When I call it, the dialog shows up (see clipboard1.jpg - sorry, but it's in my native language) and I can select the folder and change the file name, but when I klick on the Save button, the dialog closes and the file isn't saved. Then "Save your changes to this file" dialog opens asking if I would like to save the file (clipboard2.jpg).
In this second dialog the initial file name is not the same as in the first dialog, and also the location for saving not as required.

Can someone please explain why the macro isn't working?
Attached Images
File Type: jpg Clipboard1.jpg (57.0 KB, 11 views)
File Type: jpg Clipboard2.jpg (29.4 KB, 11 views)

Last edited by Franci; 01-07-2023 at 05:20 AM. Reason: adding links to pictures
Reply With Quote
  #2  
Old 01-07-2023, 08:20 PM
BrianHoard BrianHoard is offline Can't save file using a msoFileDialogSaveAs Windows 10 Can't save file using a msoFileDialogSaveAs Office 2019
Advanced Beginner
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default

Does this help?
Code:
Sub ShowSaveAsDialog()
  Dim dlgSaveAs As FileDialog
  Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  dlgSaveAs.InitialFileName = "test.docx"
  
  If dlgSaveAs.Show <> 0 Then
    dlgSaveAs.Execute
  End If
  
End Sub
Reply With Quote
  #3  
Old 01-08-2023, 08:36 AM
Italophile Italophile is online now Can't save file using a msoFileDialogSaveAs Windows 11 Can't save file using a msoFileDialogSaveAs Office 2021
Expert
 
Join Date: Mar 2022
Posts: 540
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

In the VB Editor you can use F1 to look up the online documentation for the object, method, or property the cursor is currently in.

FileDialog.Show method (Office) | Microsoft Learn

FileDialog members (Office) | Microsoft Learn
Reply With Quote
  #4  
Old 01-09-2023, 05:05 AM
Franci Franci is offline Can't save file using a msoFileDialogSaveAs Windows 10 Can't save file using a msoFileDialogSaveAs Office 2016
Novice
Can't save file using a msoFileDialogSaveAs
 
Join Date: May 2016
Posts: 12
Franci is on a distinguished road
Default

Quote:
Originally Posted by BrianHoard View Post
Does this help?
Code:
Sub ShowSaveAsDialog()
  Dim dlgSaveAs As FileDialog
  Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
  dlgSaveAs.InitialFileName = "test.docx"
  
  If dlgSaveAs.Show <> 0 Then
    dlgSaveAs.Execute
  End If
  
End Sub

Thank you Brian, that works.
Reply With Quote
  #5  
Old 01-09-2023, 05:07 AM
Franci Franci is offline Can't save file using a msoFileDialogSaveAs Windows 10 Can't save file using a msoFileDialogSaveAs Office 2016
Novice
Can't save file using a msoFileDialogSaveAs
 
Join Date: May 2016
Posts: 12
Franci is on a distinguished road
Default

Quote:
Originally Posted by Italophile View Post
In the VB Editor you can use F1 to look up the online documentation for the object, method, or property the cursor is currently in.

FileDialog.Show method (Office) | Microsoft Learn

FileDialog members (Office) | Microsoft Learn



Thank you for your suggestion.
Reply With Quote
Reply

Tags
dialog, msofiledialogsavea, save as



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't save file using a msoFileDialogSaveAs Excel 2000 Backup File Modification Date Not Changing When I Save an XLS File skeezix Excel 3 01-10-2021 04:51 PM
Can't save file using a msoFileDialogSaveAs save dialog box promt doesn't save file brmveen Word VBA 2 11-04-2015 12:51 AM
Can't save file using a msoFileDialogSaveAs Auto Save Every Page(s) as a separate file, and name each new file automatically by the first line? commissarmo Word VBA 3 03-14-2015 12:53 AM
Can't save file using a msoFileDialogSaveAs error: You are attempting to save a file format that is blocked by file block setting zatlas1 Office 8 04-28-2012 02:37 PM
Can't save file using a msoFileDialogSaveAs Word Macro: Save file as text with current file name jabberwocky12 Word VBA 2 10-22-2010 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft