I have an excel file, BookDatabase.xls, which holds a database of books and has a command button that backup some contents of a worksheet to a new excel file.
My problem is BookDatabase.xls will be used in a laptop and a desktop, how can I make this button to work in both devices.
Below is my portion of my code for the creation of the file and I'm expecting that this will not work in the other device because the path is only for the desktop.
ActiveWorkbook.SaveAs Filename:="C:\Users\Karen\Documents\BookDatabase.xls"
I'm not very good with VBA and would like to learn more. I hope you can also place a comment in the code so the I could better understand the function of the code lines.
If the problem is only that the User Name is not the same on the laptop, the following should work:
ActiveWorkbook.SaveAs Filename:=Environ("USERPROFILE") & "\Documents\BookDatabase.xls"
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments