prevent prompts in VBA

rjmdc

Well-known Member
Joined
Apr 29, 2020
Messages
693
Office Version
  1. 365
Platform
  1. Windows
i am updating a book by copying another
a popup prompt "classes need to be updated do you want to update"
how do i prevent that?
i colored the line of code red where the problem happens

Rich (BB code):
Sub GetClassesNames()
    
        
    ' GetClassesNames Macro

    Application.ScreenUpdating = False

    Dim wbApproved As Workbook
    
    Call WSUnProtect(ActiveSheet)
   
    Sheets("ClassesMemberships Names").Select
    'Columns("A:D").ClearContents
    
   
    If IsWorkBookOpen("M:\all\Rochma Jungreis\Approved Classes\Approved Classes by ABC.xlsm") = False Then
        Set wbApproved = Workbooks.Open("M:\all\Rochma Jungreis\Approved Classes\Approved Classes by ABC.xlsm")
        DoEvents
        
        Else
            MsgBox "Workbook 'Approved Classes by ABC' is already open.  Update not allowed."
Exit Sub
    End If

'    Else
'        Set wbApproved = Workbooks("Approved Classes by ABC.xlsm")
'    End If
    
    Workbooks("Approved Classes by ABC.xlsm").Activate
    Workbooks("Approved Classes by ABC.xlsm").Worksheets("ClassesMemberships Names").Columns("A:F").Copy
    DoEvents
    ThisWorkbook.Activate
    
    Worksheets("ClassesMemberships Names").Activate
    Application.EnableEvents = False
    Range("A:F").PasteSpecial xlPasteAll
    DoEvents
     
    
    Application.CutCopyMode = False
    
    'Disable Events to prevent prompt to backup Class Book
    Application.EnableEvents = False
    Workbooks("Approved Classes by ABC.xlsm").Close SaveChanges:=False
    Application.EnableEvents = True
    
    Call WSProtect(ActiveSheet)

    Application.ScreenUpdating = True
    
    MsgBox "Classes/Memberships has been updated successfuly!"
    
End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Try

Application.DisplayAlerts = False

Before the line

and then

Application.DisplayAlerts = True

After the line
 
Upvote 0
a popup prompt "classes need to be updated do you want to update"
That is not a native Excel prompt so I doubt displayalerts will help. I'm surprised it happens given that you are disabling events and there's nothing in the code you posted to produce that message.
 
Upvote 0
it is even more interesting as whn i ut a stop point on the copy then no message after i press start again
i put in a pause that didnt work either
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top