I have a script that opens an Excel spreadsheet and then goes to a specific sheet before running a macro. The problem is that this macro brings up different dialog boxes which require user input - I am trying to automate the process. I have tried to get rid of these boxes by using the following code:
import os
impor win32com.client
xl = win32com.client.Dispatch('Excel.Application')
xl = DisplayAlerts = False #Supposed to disable alert/messages/dialog boxes
wb = xl.Workbooks.Open(os.path.abspath('Test.xlsm'), ReadOnly = 0) #Opens spreadsheet
wb.Worksheets('Assets').Activate() #Activates correct sheet
wb.Application.Run('MxRunAction') #Runs macro
wb.Clost(True)
I have read on many threads that:
Application.DisplayAlerts = False
is supposed to fix this problem, yet this seems to do nothing if I substitue Application with xl for my case. Am I using it properly in this sense?
Application.DisplayAlerts = False... So, wouldn't that translate toxl.DisplayAlerts = Falseinstead ofxl = ...?DisplayAlerts(or any other setting) isn't going to change that behavior...