Word VBA environment becoming unstable, losing values, etc. (ADO problem?)

D

David Horowitz

Hi folks,
I'm having a problem where it seems the VBA environment becomes unstable
during macro execution.
I have an extensive Word VBA program that runs in a 2003 .doc file.
It seems that sporadically (around 1 of 20 runs), one of two things happens:
1) either Word just terminates with no warning, or
2) constant values, usually strings, lose their values.
The 2nd one is very weird - the code will be something like:
Sub test()
Call PrintMe("Hello")
End Sub
Sub PrintMe(ByVal s As String)
MsgBox s ' s is blank
End Sub
And the MsgBox will show a blank value. My actual code is much more
complicated, but this illustrates the general idea.
This program uses ADO 2.8 (through early binding (Tools > References)- I
don't know if that might give anyone a clue.
I've never seen anything like this before in VBA. (In C programming, you'd
expect it all the time...)
I don't know if it's a line of my code that's causing a memory overrun, or
just a Word bug I'm hitting upon, or something else.
Does anyone have any clue for me?
Thank you very much.
 
C

Cindy M.

Hi David,
It seems that sporadically (around 1 of 20 runs), one of two things happens:
1) either Word just terminates with no warning, or
2) constant values, usually strings, lose their values.

The example you show isn't a constant value, it's a variable...

I don't know of anything in ADO that would cause what you're seeing.

Have you tried starting Word in Safe Mode, to make sure there aren't any add-
ins running that might be interfering with your code's execution?

How about running Windows in Safe Mode, in order to rule out an outside
process sticking it's fingers into things?

How complex is your tool? Does it include classes, use events, other "unusual"
(for "amateur" VBA) things?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top