Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the save as prompt?

Tags:

excel

vba

Error Message

        If IsWorkbookOpen("CONTRACT\CONTRACTLIST_Cement.xlsx") Then
            x = 0
        Else
            Application.DisplayAlerts = False
            ActiveWorkbook.Close savechanges:=True
            Application.DisplayAlerts = True
        End If

Hi, despite using the above code, the save as prompt still occasionally appears and affect the program. Does anyone know how to stop it completely? The problem is that after I click save as, it will alert me that it was still open.

enter image description here

like image 446
Ting Ping Avatar asked Jul 16 '13 11:07

Ting Ping


People also ask

How do I disable the save prompt in Excel?

Disable save prompt with VBA code in Excel 1. Press Alt + F11 to open a Microsoft Visual Basic for Application window. 2. Click Insert > Module to open a Module window, then copy the following VBA to the window. VBA: Close without saving... 3. Click Run button or F5 key on the keyboard to run this ...

How to turn on or off download save prompt in Microsoft Edge?

Turn On or Off Download Save Prompt in Microsoft Edge. 1 Option One: To Turn On or Off Microsoft Edge Download Save Prompt in Download Settings. 2 Option Two: To Turn On or Off Microsoft Edge Download Save Prompt using a REG file EXAMPLE: Download prompt in Microsoft Edge OPTION ONE.

How do I Turn Off the automatic prompt when opening files?

Right-click on the file In the options presented, make sure to un-check the option labeled: Always ask before opening this type of file From now on if you click on a file of that type, the file will bypass the automatic prompt and will open automatically. This works for me on Windows 7 machines running IE 10 and 11.

How to disable Save&Save as function in Excel 2016?

1. In the workbook you need to disable the Save & Save As functions, please press Alt + F11 keys simultaneously to open the Microsoft Visual Basic for Applications window. 2.


1 Answers

Try below code

Its always good to explcilty refer the workbook rather than ActiveWorkbook

Sub test()
   If IsWorkbookOpen("CONTRACT\CONTRACTLIST_Cement.xlsx") Then
            x = 0
    Else
        Application.DisplayAlerts = False
        ThisWorkbook.Save
        ThisWorkbook.Close False
        Application.DisplayAlerts = True
    End If

End Sub
like image 126
Santosh Avatar answered Sep 23 '22 19:09

Santosh