personal macro workbook - save as

rikvny02

Board Regular
Joined
Aug 9, 2022
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Thanks in advance for your help

I had to move my macros into a personal macro workbook and now the SAVE AS macro will not work. I have several macros that i use the call function with and the last step is to save the workbook. Now that the macros are in the personal macro workbook the save as macro saves everything as "PERSONAL.XLSB". The goal would be to save the active file with its current name. ie - Rikki_ws

Current code is as follows

Sub SaveWorkbook()
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.Show
If .SelectedItems.Count > 0 Then
sPath = .SelectedItems(1)
ThisWorkbook.SaveAs Filename:=sPath & Application.PathSeparator & "Copy of " & ThisWorkbook.Name
Cancel = True
End If
End With
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
ActiveWorkbook.SaveAs Filename:=sPath & Application.PathSeparator & "Copy of " & ActiveWorkbook.Name

Or a better alternative (In case you want to save a non-active workbook ), add a workbook argument to the SUB:
VBA Code:
Sub SaveWorkbook(ByVal oWorkbook As Workbook)
    With Application.FileDialog(msoFileDialogFolderPicker)
        .AllowMultiSelect = False
        .Show
        If .SelectedItems.Count > 0 Then
            sPath = .SelectedItems(1)
            oWorkbook.SaveAs Filename:=sPath & Application.PathSeparator & "Copy of " & oWorkbook.Name
            Cancel = True
        End If
    End With
End Sub

And then you pass the workbook you want to save in the argument when calling the SUB as follows:
VBA Code:
SaveWorkbook ThisWorkbook
 
Upvote 0
Unfortunately, I get the same result. More importantly what's saved is not my workbook at all. Please see below and thank you for your time and effort.

1668613965997.png


Im looking for it to save like the below example

1668614028677.png
 
Upvote 0
Ther must be something you are doing. The code I posted should save the active workbook or the workbook you are calling the SaveWorkbook SUB from.
Is the personal .xlsb visible and\or active when you call the code ?
 
Upvote 0
Ther must be something you are doing. The code I posted should save the active workbook or the workbook you are calling the SaveWorkbook SUB from.
Is the personal .xlsb visible and\or active when you call the code ?
I change to active workbook and it works great. Thank you
 
Upvote 0
Ther must be something you are doing. The code I posted should save the active workbook or the workbook you are calling the SaveWorkbook SUB from.
Is the personal .xlsb visible and\or active when you call the code ?
I change to active workbook and it works great. Thank you
Careful when using ActiveWorkbook, as the current active workbook may not be the one you intend to save.

I would rather use the SaveWorkbook SUB I showed you in post#2 and pass it the correct workbook.
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,825
Members
449,096
Latest member
Erald

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