?
Solved

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

Posted on 2016-10-10
2
Medium Priority
?
132 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 52

Accepted Solution

by:
Rgonzo1971 earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

765 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