hi,
Need a VBA to Save Active workbook as xlsb in same i.e active workbook name and location.
Thanks in advance.
hi,
Need a VBA to Save Active workbook as xlsb in same i.e active workbook name and location.
Thanks in advance.
Re: Activeworkbook saveas xlsb in same location
Have you tried recording a macro while you save it manually?
Re: Activeworkbook saveas xlsb in same location
hi cytop,
Yes i tried to record a macro but it records the path and the path becomes constant but i don't want the path to be constant because if i open a file from some other location and want to saveas "xlsb" it will save in the recorded location and not in the active file location .
I hope this makes you understand what I want to say.
Re: Activeworkbook saveas xlsb in same location
Replace the literal path string with the value stored in the Workbook.Path property. The workbook will have to have been saved previously, it will not work if you create a new workbook as the Path property will be blank until it is saved.
Re: Activeworkbook saveas xlsb in same location
Hi cytop,
thanks for you reply but i am Sorry, i did not got you, below is code that i recorded
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\chandrakant\Desktop\Output\123.xlsb", FileFormat:= _
xlExcel12, CreateBackup:=False
here the path is constant and i don't want the path to be constant.
Re: Activeworkbook saveas xlsb in same location
The path and name of the workbook are stored in the WorkBook.Path and the Workbook.Name properties.
It is a simple matter of substituting those values instead of the literal path and name recorded by the macro.
Re: Activeworkbook saveas xlsb in same location
Hi cytop,
Sub SAVEasXLSB()
Application.ScreenUpdating = False
Dim fpath As String
Dim wname As String
wname = ActiveWorkbook.Name
fpath = ActiveWorkbook.path & "\" & wname
ActiveWorkbook.SAVEas filename:=fpath & ".xlsb", FileFormat:= _
xlExcel12, CreateBackup:=False
Application.ScreenUpdating = True
End Sub
Display More
I wrote this code and it works for me as i want but the only problem is if I open a file name 123.xlsx and run the code it saves it as 123.xlsx.xlsb is there any thing that i need to change to save it as 123.xlsb.
Thanks.
Re: Activeworkbook saveas xlsb in same location
Hi cytop,
Thanks a ton now it is perfect.:thumbcoo:
Don’t have an account yet? Register yourself now and be a part of our community!