Activeworkbook saveas xlsb in same location

  • 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


    Code
    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,



    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


    Trim off any extra information after the last '.' (dot) in the name


    Code
    wname = Left(ActiveWorkbook.Name, (InStrRev(ActiveWorkbook.Name, ".", -1, vbTextCompare) - 1))

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!