View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
MSweetG222 MSweetG222 is offline
external usenet poster
 
Posts: 158
Default VBA just stops when opening a macro workbook

Thank you everyone for your help. I tried the suggestions by Tim & Barb as
well. Barb, I did add your code also, because I do multi-task and it could be
a combination of things. :)

I finally got it to work. This is what I had to do.

1. Clean code
2. Set EnableEvents = False
3. Set AutomationSecurity = 1
4. Check for Shift Key
5. Open the workbook
6. Set AutomationSecurity = 3
7. Re-enable EnableEvent = True

Just to let you know, I did try setting security to low via the user
interface panel and that did not help.

Does anyone see a problem with setting security to low while EnableEvents is
set to False for the few seconds it takes to get the workbook open?

Can a malicious macro run if EnableEvents is set to false when you open the
workbook?

P.S. Sorry it took so long to respond. I am have a dickens of a time
posting to the board. I keep getting Service Temp Unavailable.
--
Thx
MSweetG222



"Barb Reinhardt" wrote:

I bet you're multitasking while this macro is being run and you are typing
the shift key during execution. Read on here.

http://www.jkp-ads.com/Articles/WorkbookOpenBug.asp

I've used this for a while and since I've moved to 2007, I've run into
trouble because I believe I'm having a bit of a delay between testing for the
shift key and the workbook opening. Hopefully it'll work now while I'm
typing this, because I have it in code that is executing now.

HTH,
Barb Reinhardt

"MSweetG222" wrote:

Hello,

I have written VBA code to open workbooks, perform procedures and then saves
and close the workbooks. Every thing works just fine until I get to a
workbook that has a macro, then my VBA stops just after the workbook with the
macro is opened.
No error messages. It just stops. The call stack totally disappears.

I have tried turning off events just before opening the workbook with the
macro, but that did not work.

I have tried "On Error" statements, that did not work.

I have tried signing with workbook with a trusted certificate, did not help.

QUESTION: What do I need to do to open macro workbooks and perform my
procedures with out my VBA terminating like this?

Example:

Application.EnableEvents = False
Workbooks.Open Filename:= "C:\Test\ExcelWB_Template.xls"
' This is where my VBA just stops
Range("A1").FormulaR1C1 = "ABC Company"
Range("A2").FormulaR1C1 = "123"

--
Thx
MSweetG222