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)?
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.
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.
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.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With