Automatically click ok on message box

Biz

Well-known Member
Joined
May 18, 2009
Messages
1,773
Office Version
  1. 2021
Platform
  1. Windows
Dear All,

File 1 has vba that opens an another Excel file File 2 and runs vba stored in File2.
Once vba in File 2 finishes running then it display message to click ok.

Is it possible to automatically click "ok" to message box?

Biz
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi ,

This does not work at all. Msgbox is created vba in File 2 as basis user notification. I can't change that file.

Is it possible to stop message box appearing? I have used code below on start code in File 1

Code:
'Speeding Up VBA Code
 With Application
    .ScreenUpdating = False 'Prevent screen flickering
    .Calculation = xlCalculationManual 'Preventing calculation
    .DisplayAlerts = False 'Turn OFF alerts
    .EnableEvents = False 'Prevent All Events
End With

Biz
 
Upvote 0
Hi

Are you able to modify the code in File2? Ideally you would modify it so that you could specify an optional flag that indicates whether you want it to display the message box or not. Here is a simple example:

Code:
Sub Testing()

    'First of all run the process using default settings.
    'It will display a message.
    SomeProcess


    'Now specify that you don't want any user interaction (i.e. anything that requires human input)
    SomeProcess UserInteract:=False


End Sub



Sub SomeProcess(Optional UserInteract As Boolean = True)


' do something
    Debug.Print "In Someprocess and UserInteract=" & UserInteract



    If UserInteract Then
        MsgBox "Macro in file 2 has finished.", vbOKOnly, ""
    End If


End Sub


HTH
DK
 
Upvote 0
Hi ,

This does not work at all. Msgbox is created vba in File 2 as basis user notification. I can't change that file.

Is it possible to stop message box appearing? I have used code below on start code in File 1

Code:
'Speeding Up VBA Code
 With Application
    .ScreenUpdating = False 'Prevent screen flickering
    .Calculation = xlCalculationManual 'Preventing calculation
    .DisplayAlerts = False 'Turn OFF alerts
    .EnableEvents = False 'Prevent All Events
End With

Biz

Application.DisplayAlerts doesn't work with VBA message boxes. If you're not able to modify the code in File2 then I don't know what else you can do.
 
Upvote 0
Hi dk,

I know this difficult question because I can't modify macro in File 2.

Hoping someone has a way to do this.

Biz
 
Upvote 0
Hi DK,

Your approach does work and I have implemented it.
Thank you for crafty solution.:beerchug:
Biz

Hi

Are you able to modify the code in File2? Ideally you would modify it so that you could specify an optional flag that indicates whether you want it to display the message box or not. Here is a simple example:

Code:
Sub Testing()
 
    'First of all run the process using default settings.
    'It will display a message.
    SomeProcess
 
 
    'Now specify that you don't want any user interaction (i.e. anything that requires human input)
    SomeProcess UserInteract:=False
 
 
End Sub
 
 
 
Sub SomeProcess(Optional UserInteract As Boolean = True)
 
 
' do something
    Debug.Print "In Someprocess and UserInteract=" & UserInteract
 
 
 
    If UserInteract Then
        MsgBox "Macro in file 2 has finished.", vbOKOnly, ""
    End If
 
 
End Sub


HTH
DK
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,239
Members
452,898
Latest member
Capolavoro009

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