Saving a Workbook - Excel 2013

Rocky0201

Active Member
Joined
Aug 20, 2009
Messages
278
Hi,

I have a Macro Enabled Workbook (Workbook A) that I use GetOpenFilename to open another Workbook (Workbook B). After changing data in Workbook B from Workbook A, I wish to do a Save As on Workbook B from Workbook A.

Is this possible?

In Workbook A I have the following code:

Private Sub CommandButton7_Click()


Workbooks(TextBox1.Value).Activate ' Activate the Workbook previously opened using GetOpenFilename

FName = Application.GetSaveAsFilename(InitialFileName:=TextBox1.Value, _
FileFilter:="Excel Files (*.xlsx), *.xlsx", Title:="DMS File To Be Saved")
If FName = False Then Exit Sub

End Sub

The Save As Dialog box is presented. When I update the File Name to Save and then press the Save button, return back to my code occurs and FName is not False (it contains the path and filename that I am trying to save).

The problem is, the file I am saving does not exits.

Any help would be appreciated.

Thanks
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
See if I'm understanding you correctly here. The only issue you are having is that the file does not close when finished? I'm not sure if this is a type, and you meant exit or did you mean exist? "The problem is, the file I am saving does not exits".

If you just need to exit, then you'll need something like this (modified to suit your needs). This is actually closing a workbook the code was modifying, and then closing the workbook that actually contains the code. This also gives an example of saving changes, or not saving them:

Code:
 Windows("export.MHTML").Activate
                    ActiveWorkbook.Close SaveChanges:=False                    
                   
            With ThisWorkbook
                    Saved = True
                    .Close
            End With
 
Last edited:
Upvote 0
Thanks for your response, Kentetsu.

I meant exist... I do not receive any errors with using the Save As Dialog. After I press the Save Button, the dialog box disappears and control is back to my routine. I go into Windows Explorer to look for the file I just saved and it does not exist.
 
Upvote 0
Okay, sorry about that. I've never attempted to use an automated "save as" before, so I'll just stand back and watch at this point. Someone smart should be along shortly. :)
 
Upvote 0
Don't sell yourself short... Your examples above could be a very big help if the GetSaveAsFilename Dialog does not work for me.

Thanks Kentetsu. Hopefully someone will respond.
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top