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

A few ideas to help debug, not necessarily in order.

Close Excel and reopen.

Replace ExcelWB_Template.xls with a fresh new workbook with no macros and no
data, then run the macro, to see if that fixes it. Also, move just the
relevant portion of the workbook-opener code to a fresh new workbook and see
if it can open the existing ExcelWB_Template.xls. The idea here is to see
whether the problem lies with the calling workbook or target workbook

Are you using error handling prior to opening the workbook? E.g. On Error
Resume Next? If so comment that out so that no errors are suppressed.

Clean the code in the calling workbook using a code cleaner (e.g. Rob
Bovey's code cleaner).

Step through the code manually and then execute it in its current state
(e.g. via a button click event). Is there any difference?

See if there is anything wrong with WB_Template.xls such as illegal sheet
names, invalid range names, bad links or some other problem.



--
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility
Free and Pro versions

"MSweetG222" wrote in message
...
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