Solved

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

Posted on 2016-10-10
2
107 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 51

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

707 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