We help IT Professionals succeed at work.

Macro Recording

Ibukunkapital
on
I am trying to record a macro to save copy of opened workbook as a filepath
Comment
Watch Question

Top Expert 2015
Commented:
You can use the following code to do what you are looking for...

Sub savewb()
Dim wb As Workbook
Dim xpath As String, xname As String
Dim spath As String

Set wb = ActiveWorkbook

xpath = "Your file path here"
xname = "Your workbook name which you want to give at time save"
spath = xpath & "\" & xname

wb.Save Filename:=spath & ".xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
wb.Close (True)

End Sub

Open in new window


Saurabh...
Phillip BurtonDirector, Practice Manager and Computing Consultant
Awarded 2014
Top Expert 2014

Commented:
Activeworkbook.saveas "c:\mypath\myname.xlsx"