Re: Sending debugging messages to a second document.
- From: "Jay Freedman" <jay.freedman@xxxxxxxxxxx>
- Date: Wed, 7 Nov 2007 11:49:14 -0500
Instead of opening the log file at the beginning of the macro, writing a
bunch of lines, and closing the log file at the end of the macro, you'll
have to open/write/close for each log message. Normally this would be too
resource-intensive, but in this case it's necessary because VBA doesn't have
any sort of "flush buffer" method other than Close.
This will require using For Append in the Open statement instead of For
Output, to avoid clearing the file each time.
It would probably be best to write this as a subroutine that takes the log
message as a parameter (and possibly the filename of the log, if you want it
to be generally reusable).
Barry wrote:
Jay:
With some minor modification, your example code is working, up to a
point. Apparently the OS or Word or something is buffering the writes
to the log file. By the time the macro hangs, only a small portion
of the trace statements have been written out; the rest are lost when
the hang occurrs.
Can you tell me how to force immediate writes to the log file, so
that I don't lose state of the macro at the time or the error?
Thank you for your help.
Barry wrote:
I am debugging a VBA subroutine that hangs under certain conditions.
In order to pinpoint the spot in the code where the hang occurs, I
want to write trace data to a second document, where they will not
interfere with the text and ActiveX controls being added to the
target document. I know that this is pretty elementary VBA, but
I've never done it before and can't seem to make it work.
Can someone show me or point me to an example of how this is done?
Thanks in advance for any help.
See this thread from yesterday:
http://groups.google.com/group/microsoft.public.word.vba.beginners/browse_thread/thread/c0e61d07da657f08/2d848ae91240c9ea?hl=en&lnk=st&q=#2d848ae91240c9ea
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
.
- References:
- Re: Sending debugging messages to a second document.
- From: Jay Freedman
- Re: Sending debugging messages to a second document.
- From: Barry
- Re: Sending debugging messages to a second document.
- Prev by Date: Re: linkage between word files
- Next by Date: Re: Round function evaluates to zero if bookmark is hidden text
- Previous by thread: Re: Sending debugging messages to a second document.
- Next by thread: RE: run-time error 13 - Type mismatch (don't know why)
- Index(es):
Relevant Pages
|