Open Save As Dialog box defaulting to specified drive

mandii01

New Member
Joined
Mar 21, 2011
Messages
11
Hi All,

I'm have a few issues, I'm attempting to set up a vba code that links to a "save" button in my excel workbook.

My original file is located in Drive H:\ but I want the vba code to open the save as dialog box (which it does) but I'm wanting it to default to G:\Community\Assessments\

Unfortunately the below code is not accessing the default drive/folder that I'm wanting to save in, and it is also coming up with a Run-time error '1004' Method 'SaveAs' of object'_Workbook' failed.

I want to also ensure that the saved files save as .xlsm files.

I have the following code (in Module3);

Sub SaveAs()
ActiveSheet.Unprotect Password:="Password"
Application.Dialogs(xlDialogSaveAs).Show
ActiveWorkbook.SaveAs Filename:=("G:\Community\Assessments\")
ActiveSheet.Protect


End Sub

Any assistance on this is greatly appreciated, I have been trying to get this to work all day without success.

Thanks :)
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Check out

[TABLE="width: 100%"]
<TBODY>[TR]
[TD="align: left"]Application.GetSaveAsFilename Method</STRONG>[/TD]
[/TR]
</TBODY>[/TABLE]
Displays the standard Save As</STRONG> dialog box and gets a file name from the user without actually saving any files. Syntax</STRONG>
expression</EM>.GetSaveAsFilename(InitialFilename, FileFilter, FilterIndex, Title, ButtonText)
expression</EM> A variable that represents an Application object.

something like
meme = Application.GetSaveAsFilename("G:\Community\Assessments\","Excell Macro-Enabled workbook (*.xlsm), *.xlsm", , "Go man")

If RIGHT(TRIM(meme),5)<>".xlsm" then

msgbox "Bad user Bad"

 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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