Error Using Datanitro/VBA to Turn Off Screen Updating

1

I am using Datanitro to build a program that gathers data from a number of workbooks and dumps it into a master workbook.

The program is working fine, although it runs slower than I would prefer and every time I run close_wkbk() excel asks me if I want to save the workbook (I do not).

To solve this using VBA, I would bracket the program with the following snippets of code:

With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

It did not seem as though Datanitro supported this functionality, so I created the following two VBA subroutines in a module within the workbook from which I was running the script:

Sub RemoveAlerts()
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
End Sub

Sub DisplayAlerts()

With Application
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With

End Sub

I then bracketed my python script with the following code:

VBA("RemoveAlerts")

VBA("DisplayAlerts")

RemoveAlerts appears to execute correctly, but DisplayAlerts threw the following error message

, line 48, in grab_all_intrinsic_values
VBA("DisplayAlerts")
File "27/basic_io.py", line 1850, in VBA 
File "27/iron.py", line 305, in runExcelMacro 
File "27/dnparser.py", line 95, in checkForErrors
dntypes.NitroException: The object invoked has disconnected from its clients.
(Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))

Any idea what is causing this error?

BELOW EDIT INCLUDED WHEN ANSWER WAS FOUND:

Turns out that the problem was my active_workbook had changed to a workbook that did not contain the DisplayAlerts subroutine. I made sure to set my active_workbook back to the one that did contain the subroutine and it worked correctly.

datanitro
asked on Stack Overflow Dec 14, 2013 by DFT

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0