Hello,
Briefly I have a macro that saves my current workbook as two different files--one that is macro enabled and one that isn't.
Runs well.
HOWEVER, I cannot for the life of me get my second file to save based off the name of the first file.
For example, if my first file is saved as "Hippo" I would like the second file to be saved as "HippoVersion2"
The name of my first workbook changes occasionally so I need the second workbooks name to change as well.
So all I'm looking for is a solution to get the string of my work books name correct.
As of now all it does is save my second file as WorkbookName + Version2 (it's not recognizing my saved string value).
Cheers.
Briefly I have a macro that saves my current workbook as two different files--one that is macro enabled and one that isn't.
Runs well.
HOWEVER, I cannot for the life of me get my second file to save based off the name of the first file.
For example, if my first file is saved as "Hippo" I would like the second file to be saved as "HippoVersion2"
The name of my first workbook changes occasionally so I need the second workbooks name to change as well.
So all I'm looking for is a solution to get the string of my work books name correct.
As of now all it does is save my second file as WorkbookName + Version2 (it's not recognizing my saved string value).
Cheers.
Code:
Sub SaveWorkbook()
Dim wb As Workbook, wb2 As Workbook
Dim Path As String
Dim WorkbookName As String
WorkbookName = ActiveWorkbook.Name
Application.DisplayAlerts = False
Path = "C:\Users\" & Environ("Username") & "\Desktop\"
Set wb = ThisWorkbook
wb.SaveCopyAs (Path & "File.xlsm")
Set wb2 = Workbooks.Open(Path & "File.xlsm")
wb2.SaveAs Path & "WorkbookName + Version2.xlsx", xlOpenXMLWorkbook
wb2.Close
Application.DisplayAlerts = True
End Sub
Last edited: