Save As Dialog Box VBA

michaelp1029

Board Regular
Joined
Jul 15, 2008
Messages
63
Here's what I need to do. I need to press a button and have the file I am currently to saved to a folder called "N:\Group\Gateway\McCarthy's Sausage Factory\Jim Monthly Reports". So I need a macro that brings up a Save As dialog box and automatically goes to this folder. I am a beginner macro guy so some help would be appreciated.

Danke!!

Mike
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Code:
Sub Test()
  SaveAs "N:\Group\Gateway\McCarthy's Sausage Factory\Jim Monthly Reports\"  & _
Format(Date, "yyyymmdd") & ".xls"
End Sub

Sub SaveAs(initialFilename As String)
  With Application.FileDialog(msoFileDialogSaveAs)
    .AllowMultiSelect = False
    .ButtonName = "&Save As"
    .initialFilename = initialFilename
    .Title = "File Save As"
    .Execute
    .Show
  End With
End Sub
 
Upvote 0
Everything in the code works but the file doe snot actually save to the folder. Everything goes through like it's supposed to. It pulls up the Save As dialog box in the folder I want but when I press save, the file doesn't save. I am using the exact code in the previous post
 
Upvote 0
This will give you more flexibility.
Code:
Sub Test()
  Dim myPath As String, v
  myPath = "N:\Group\Gateway\McCarthy's Sausage Factory\Jim Monthly Reports\" & _
    Format(Date, "yyyymmdd") & ".xls"
  'myPath = "x:\" & Format(Date, "yyyymmdd") & ".xls"
  v = SaveAs(myPath)
  If v <> False Then ThisWorkbook.SaveAs v
End Sub

Function SaveAs(initialFilename As String)
  On Error GoTo EndNow
  SaveAs = False
  With Application.FileDialog(msoFileDialogSaveAs)
    .AllowMultiSelect = False
    .ButtonName = "&Save As"
    .initialFilename = initialFilename
    .Title = "File Save As"
    '.Execute
    .Show
    SaveAs = .SelectedItems(1)
  End With
EndNow:
End Function
 
Upvote 0

Forum statistics

Threads
1,214,839
Messages
6,121,887
Members
449,057
Latest member
Moo4247

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