Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save Excel Workbook to Desktop regardless of user?

Tags:

I have an Excel Workbook that on Form Button click I need to save a copy of the workbook to the user's Desktop.

Originally everything was going to be on a shared Network folder, but now I have about 6 different users that when they click the button, I need to save the workbook to their individual Desktops.

Is their a way (coding-wise) to save to the machine Desktop without having to specify individual users (which would require me to maintain 6 different Workbook files)?

like image 904
Analytic Lunatic Avatar asked Jul 09 '13 14:07

Analytic Lunatic


People also ask

How do I save an Excel spreadsheet to my desktop?

Click File > Save As. Under Save As, pick the place where you want to save your workbook. For example, to save to your desktop or in a folder on your computer, click Computer.

How to save workbook in desktop using VBA?

To make the above VBA code more dynamic (no path to the desktop required) we can trap the desktop path using the WScript. Shell command. The following will save the active workbook to the desktop no matter the path. Sub SavetoDesktop2() 'Excel VBA to save a file to the desktop with a dynamic Path.

How do I save an Excel file using VBA code?

To save an Excel workbook using VBA, you need to use the SAVE method to write a macro. And in that macro, you need to specify the workbook that you want to save and then use the SAVE method. When you run this code, it works like the keyboard shortcut (Control + S). Specify the workbook hat you want to save.


1 Answers

I think this is the most reliable way to get the desktop path which isn't always the same as the username.

MsgBox CreateObject("WScript.Shell").specialfolders("Desktop") 
like image 125
SWa Avatar answered Oct 03 '22 02:10

SWa