Solved

How to skip the SAVE AS dialog box in an Excel Macro

Posted on 2016-10-10
2
88 Views
Last Modified: 2016-10-10
Hi,

I currently have a macro to save as when a certain cell is changed and then input that cell as the name for the new workbook.

The problem is simply that when it does save, the save as dialog box appears.

And I've done it so it automatically changes the name around this box so whatever is put into the filename at this point will not do anything.

Is there a way to just hit the 'save' button, or skip the box entirely?

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("C16")) Is Nothing Then
    Exit Sub
    Else
   fileSaveName = Application.GetSaveAsFilename( _
   fileFilter:="Excel Files (*.xlsm), *.xlsm")

   If fileSaveName <> False Then
      Dim thisWb As Workbook
      Filename = "\Invoice " & Range("C16")
      Set thisWb = ActiveWorkbook
      thisWb.SaveAs thisWb.Path & Filename, FileFormat:=xlOpenXMLWorkbookMacroEnabled
     
      If fileSaveName <> False Then
            MsgBox "Saved as " & thisWb.Path & Filename
    End If
   End If
    End If
End Sub


Thanks!
0
Comment
Question by:Al Co
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41836849
Hi,

pls try

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim thisWb As Workbook
    If Intersect(Target, Range("C16")) Is Nothing Then
        Exit Sub
    Else

        Filename = "\Invoice " & Range("C16")
        Set thisWb = ActiveWorkbook
        thisWb.SaveAs thisWb.Path & Filename, FileFormat:=xlOpenXMLWorkbookMacroEnabled
        MsgBox "Saved as " & thisWb.Path & Filename
    End If
 End Sub

Open in new window

Regards
1
 

Author Comment

by:Al Co
ID: 41836883
Mate that's awesome! Works perfectly, knew I'd overdone it haha
Cheers
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question