Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

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

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

609 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