To save a .xlsm file in a specific folder of a local drive

SUBHAS1812

New Member
Joined
Jul 15, 2020
Messages
2
Office Version
  1. 2007
Platform
  1. Windows
Hi

Presently I am working with a .xlsm file where one PRINT, REFRESH and SAVE AS button are required. However, the PRINT and REFRESH buttons are properly functioning. But I am unable to write the code / VBA syntax for the SAVE AS option

If you kindly help me with the VBA code so that the file is saved in a distinct file within a specified folder of a local drive. In this process, a dialogue box is supposed to appear each time to incorporate the file name while saving it in a specific folder of a local drive.

Thank you for any ideas or code syntax you might suggest, and let me know if there are any details I have left out that you need to respond.

Subhashis
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
You will need to modify the STRPATH constant to point to your desired save folder (and you might want to play around with the file format as it will default to the file format of the original workbook), but this should do what you need:

VBA Code:
Sub SaveMe()

Dim strFileName As String
Const STRPATH As String = "C:\YourOwnPathShouldGoHere\"

'Prompt User For File Name
strFileName = InputBox("Under what file name " & _
   "would you like to save this file?")

'Save File
If strFileName = "" Then

   MsgBox "Okay, fine. Don't save this file then."
   Exit Sub
   
Else

   ThisWorkbook.SaveAs STRPATH & strFileName
   
End If

End Sub
 
Upvote 0
Sir,
At the outset thank you very much for your time and attention to my concern. However, regret to inform you that as directed by you I have amended the STRPATH without any outcome.
While clicking on the SAVE AS button no changes/differences noted in the worksheet.m
Can I expect to hear from you in an affirmative note to resolve the issue?
Thank you once again for your time and attention.

With kind regards

Subhashis Chowdhury
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top