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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,214,947
Messages
6,122,413
Members
449,082
Latest member
tish101

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