Create a new file in any desktop using an excel file with a command button to execute that task

Karen88

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.

Ron Rosenfeld

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create a .desktop file that opens and execute a command in a terminal

From Dev

Create a .desktop file that opens and execute a command in a terminal

From Dev

How to create new command to execute a batch file with Sublime Text?

From Dev

desktop file in ubuntu does not execute command

From Dev

How to create a new file in a folder on the desktop with AppleScript?

From Dev

Execute a command when add a new file in folder

From Dev

Execute a command when add a new file in folder

From Dev

How to create new sheets on condition in excel file using c#

From Dev

How to create a new empty file / template file in Ubuntu 16.10 Desktop?

From Dev

execute task in .rb file

From Dev

Is there any way to decrypt a file create with the following command?

From Dev

pkexec command in a .desktop file

From Dev

pkexec command in a .desktop file

From Dev

using File class to create new text file

From Dev

Create Excel File Using jExcel

From Dev

Gradle: How to execute task after create lib.aar file?

From Dev

Can't Execute .desktop File

From Dev

Can't Execute .desktop File

From Dev

How to create a ".desktop" file?

From Dev

How to create a ".desktop" file?

From Dev

How to direct to file folder and execute specific file using batch command

From Dev

AutoIT Create New, valid Excel File

From Dev

Execute a command in a separate file

From Dev

How to make shell to execute command file without making a new process?

From Dev

Play any audio file using VBA Excel

From Dev

Can I create a new file, and open it in a new tab in a single command?

From Dev

Make Grunt Usemin HTML Task Create New File Instead Of Rewriting

From Dev

Make Grunt Usemin HTML Task Create New File Instead Of Rewriting

From Dev

Is there a way to import a file into Github without using the desktop version or command line?

Related Related

  1. 1

    Create a .desktop file that opens and execute a command in a terminal

  2. 2

    Create a .desktop file that opens and execute a command in a terminal

  3. 3

    How to create new command to execute a batch file with Sublime Text?

  4. 4

    desktop file in ubuntu does not execute command

  5. 5

    How to create a new file in a folder on the desktop with AppleScript?

  6. 6

    Execute a command when add a new file in folder

  7. 7

    Execute a command when add a new file in folder

  8. 8

    How to create new sheets on condition in excel file using c#

  9. 9

    How to create a new empty file / template file in Ubuntu 16.10 Desktop?

  10. 10

    execute task in .rb file

  11. 11

    Is there any way to decrypt a file create with the following command?

  12. 12

    pkexec command in a .desktop file

  13. 13

    pkexec command in a .desktop file

  14. 14

    using File class to create new text file

  15. 15

    Create Excel File Using jExcel

  16. 16

    Gradle: How to execute task after create lib.aar file?

  17. 17

    Can't Execute .desktop File

  18. 18

    Can't Execute .desktop File

  19. 19

    How to create a ".desktop" file?

  20. 20

    How to create a ".desktop" file?

  21. 21

    How to direct to file folder and execute specific file using batch command

  22. 22

    AutoIT Create New, valid Excel File

  23. 23

    Execute a command in a separate file

  24. 24

    How to make shell to execute command file without making a new process?

  25. 25

    Play any audio file using VBA Excel

  26. 26

    Can I create a new file, and open it in a new tab in a single command?

  27. 27

    Make Grunt Usemin HTML Task Create New File Instead Of Rewriting

  28. 28

    Make Grunt Usemin HTML Task Create New File Instead Of Rewriting

  29. 29

    Is there a way to import a file into Github without using the desktop version or command line?

HotTag

Archive