Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

VBA Saveas in local folder. Excel worksheet needs to be transferable to different computers.?

Here is my code as of now:

ActiveWorkbook.SaveAs Filename:= _

"c:Work stuff\timesheets\completed\" & Range("a1") & ".xls" _

, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _

ReadOnlyRecommended:=False, CreateBackup:=False

This works fine on my computer but, If I transfer this to a new computer it won't save where the user wants.

I want it to save in the local folder that they opened it from.

ActiveWorkbook.SaveAs Filename:= _

"...timesheets\completed\" & Range("a1") & ".xls" _

blah blah blah

Obviously this wouldn't work but i want to save in the folder timesheets\completed with main directory of where ever the user is working from.

ex. D:\\Employee Records\timesheets\completed\range(a1)

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    You can use the workbook name and fullname to help you. Name gives you the filename of the workbook. Fullname is the full pathname. You can use name to remove filename from the path.

    For example

    fullname =>c:\user\files\myfile.xls

    name => myfile.xls

    path = workbook.fullname.path( _

    len(workbook.fullname) - len(workbook.name))

Still have questions? Get your answers by asking now.