View Single Post
  #5   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

OssieMac,

I inserted your line code just after the workbook open code and the VBA
never even made it to that line. I even stepped thru the code 1 line at a
time using the f8 key, no change in results. The VBA died just after the
workbook was opened.

Just to let you know, I also turned off all addins (including COMs listed
under the COM addin box). No change. There is an Adobe PDF addin but I
can't find where to turn that off. When I find it, I will try your idea
again.

Thank your for the suggestion.

--
Thx
MSweetG222



"OssieMac" wrote:

Your code appears to work OK under test so I can't be sure of exactly what
the problem is but it might be that Excel is attempting to compile macros or
recalculate while the code is attempting to write to the worksheet.

I don't really know if this will help or not but try placing a wait command
immediately after the workbook open line. I understand that the VBA code
stops until the wait time has expired but background activity continues. This
might allow Excel to finsh what it is attempting to do after opening the
workbook. Test with different wait periods. The following waits for 10 secs.

Application.Wait (Now + TimeValue("0:00:10"))


--
Regards,

OssieMac


"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