Method SaveAs of object '_Workbook' failed

BenGreenhill98

New Member
Joined
Oct 13, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm trying to create a button that, when clicked, saves the whole file to a defined location under a name that is a concatenation of 3 cells. Here's my code so far but i'm clearly doing something wrong

VBA Code:
Private Sub CommandButton1_Click()

    Dim strPath As String
    Dim strFolderPath As String
    

    strFolderPath = "H:\Desktop\"

    strPath = strFolderPath & _
        Range("A2").Value & _
        Range("E2").Value & _
        Range("F2").Value & ".xlsm"

    ActiveWorkbook.SaveAs Filename:=strPath

End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
well it’ll be different each time I hit the button but an example is “1234578 Ben Greenhill”. I.e it’s an number, text, text
Assuming there are no forbidden characters for file names in those strings, try:

ActiveWorkbook.SaveAs Filename:=strPath, fileformat:= 52
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,932
Members
452,539
Latest member
delvey

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