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
 

Some videos you may like

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.

ajetrumpet

Banned for being rude
Joined
Apr 12, 2008
Messages
569
Office Version
  1. 365
  2. 2016
  3. 2007
Platform
  1. Windows
try googling this:

ms excel save as VBA
 

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,160
Office Version
  1. 365
Platform
  1. Windows
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
 

michaelp1029

Board Regular
Joined
Jul 15, 2008
Messages
63
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
 

Kenneth Hobson

Well-known Member
Joined
Feb 6, 2007
Messages
3,160
Office Version
  1. 365
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,623
Messages
5,625,938
Members
416,143
Latest member
JoyceMB

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
Top