Solved

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

Posted on 2016-10-10
2
45 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
2 Comments
 
LVL 48

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now