[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.excel.programming

Suppressing the Disable/Enable Macros Message Box Programmatically

Mark Dev

12/14/2006 2:51:00 PM

All,

Windows XP, Excel 2002

I have some VBA code which opens specified workbooks and loops through all
code modules, exporting each one.

Problem: When some of the workbooks are opened, I get a message complaining
about missing references. I want to suppress this message and just continue
with exporting the modules.

I have tried using "Application.AutomationSecurity =
msoAutomationSecurityForceDisable", which does the trick, but it also
instantly terminates my code as well. "Application.DisplayAlerts = False"
also does nothing to suppress this message.

Is there a way to programmatically suppress these messages?

Thanks,
Mark D.


1 Answer

Jim Rech

12/14/2006 8:21:00 PM

0

>>but it also instantly terminates my code as well

That didn't seem right to me but I did a test and you are correct. In the
following code the last line, closing the just opened workbook, does not get
executed:

Sub a()
Application.AutomationSecurity = _
msoAutomationSecurityForceDisable
Workbooks.Open "book2.xls"
ActiveWorkbook.Close False
End Sub

But here is a way around that using OnTime. Granted you do have to rearrage
your code a little to impliment this:

Sub a()
Application.AutomationSecurity = _
msoAutomationSecurityForceDisable
Application.OnTime DateAdd("s", 0, Now), "Continue"
Workbooks.Open "book2.xls"
End Sub

Sub Continue()
ActiveWorkbook.Close False
End Sub



--
Jim
"Mark Dev" <dagostam@hotmail.com> wrote in message
news:6xdgh.6$ij4.3@newsfe10.lga...
| All,
|
| Windows XP, Excel 2002
|
| I have some VBA code which opens specified workbooks and loops through all
| code modules, exporting each one.
|
| Problem: When some of the workbooks are opened, I get a message
complaining
| about missing references. I want to suppress this message and just
continue
| with exporting the modules.
|
| I have tried using "Application.AutomationSecurity =
| msoAutomationSecurityForceDisable", which does the trick, but it also
| instantly terminates my code as well. "Application.DisplayAlerts = False"
| also does nothing to suppress this message.
|
| Is there a way to programmatically suppress these messages?
|
| Thanks,
| Mark D.
|
|