Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Debug.Print statement causes Excel crash

After some search effort I found the cause for an Excel crash. Just in case you experience the same this is what I discovered:

In Excel 2003, 2007 (and later?) the statement

Debug.Print , "test"

causes Excel to crash. There is an <empty expression in front of the comma. The crash occurs only when a piece of VBA is executed without the Visual Basic editor window opened.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Debug.Print statement causes Excel crash

wrote:
After some search effort I found the cause for an Excel crash.
Just in case you experience the same this is what I discovered:
In Excel 2003, 2007 (and later?) the statement
Debug.Print , "test"
causes Excel to crash. [....] The crash occurs only when a piece
of VBA is executed without the Visual Basic editor window opened.


I think there is more to this than meets the eye.

No problem for me with XL2003 using either of the following with the VBA
window closed.

Function myfunc()
Debug.Print , "test"
End Function

Sub mysub()
Debug.Print , "test"
End Sub

The function is invoked with the formula =myfunc(). The subroutine is
executed by pressing alt-F8, then clicking on Run.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Debug.Print statement causes Excel crash

joeu2004 wrote:

wrote:
After some search effort I found the cause for an Excel crash.
Just in case you experience the same this is what I discovered:
In Excel 2003, 2007 (and later?) the statement
Debug.Print , "test"
causes Excel to crash. [....] The crash occurs only when a piece
of VBA is executed without the Visual Basic editor window opened.


I think there is more to this than meets the eye.

No problem for me with XL2003 using either of the following with the VBA
window closed.

Function myfunc()
Debug.Print , "test"
End Function

Sub mysub()
Debug.Print , "test"
End Sub

The function is invoked with the formula =myfunc(). The subroutine is
executed by pressing alt-F8, then clicking on Run.


Same here, Excel 2007 and Excel 2010. I'd suggest that the OP try stepping
through the code that crashes and see what's happening there. It generally
takes some extraordinary measures to get Excel to crash.

--
Be yourself by yourself. Stay away from me.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Debug.Print statement causes Excel crash

On Saturday, June 15, 2013 1:06:07 PM UTC+2, wrote:
After some search effort I found the cause for an Excel crash. Just in case you experience the same this is what I discovered: In Excel 2003, 2007 (and later?) the statement Debug.Print , "test" causes Excel to crash. There is an <empty expression in front of the comma. The crash occurs only when a piece of VBA is executed without the Visual Basic editor window opened.


Try This: Add a module with the following sub:

Private Sub Auto_Open()
Debug.Print , "Test"
End Sub

Save and close the Excel document; Close the Excel application.
Then open the Excel document from the Windows Explorer and allow the macro to run. Excel will crash: "Microsoft Office Excel has encountered a problem and needs to close. We are sorry for the inconvenience."
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Debug.Print statement causes Excel crash

In message of
Sat, 15 Jun 2013 23:48:43 in microsoft.public.excel.programming,
writes
On Saturday, June 15, 2013 1:06:07 PM UTC+2, wrote:
After some search effort I found the cause for an Excel crash. Just
in case you experience the same this is what I discovered: In Excel
2003, 2007 (and later?) the statement Debug.Print , "test" causes
Excel to crash. There is an <empty expression in front of the comma.
The crash occurs only when a piece of VBA is executed without the
Visual Basic editor window opened.


Try This: Add a module with the following sub:

Private Sub Auto_Open()
Debug.Print , "Test"
End Sub

Save and close the Excel document; Close the Excel application.
Then open the Excel document from the Windows Explorer and allow the
macro to run. Excel will crash: "Microsoft Office Excel has encountered
a problem and needs to close. We are sorry for the inconvenience."


Thanks for trying again. I did not bother reporting my failure to make
Excel 2003 crash with your earlier description.

I am sorry to report that I tried what you said and Excel did not crash.
When I followed up the opening with Alt+F11 to open the Visual Basic
Editor, I see the code:
Private Sub Auto_Open()
Debug.Print , "Test"
End Sub
and an Immediate window showing:
Test

Do you have a second machine on which to repeat the test with a clean
Excel installation?

I am afraid I can only say what a developer used to say to me, "It works
on my machine." ;)
--
Walter Briscoe


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Debug.Print statement causes Excel crash

wrote:
wrote:
The crash occurs only when a piece of VBA is executed
without the Visual Basic editor window opened.


Try This: Add a module with the following sub:
Private Sub Auto_Open()
Debug.Print , "Test"
End Sub
Save and close the Excel document; Close the Excel application.
Then open the Excel document from the Windows Explorer and
allow the macro to run. Excel will crash: "Microsoft Office
Excel has encountered a problem and needs to close. We are
sorry for the inconvenience."


Previously, you said "without the Visual Basic editor window open". We
cannot execute a __Private__ Sub directly without the VBE window open. (The
operative word is "directly".)

I suggest that you upload an example Excel file to a file-sharing website,
then post the URL for us to download it. The following is a list of some
free file-sharing websites; or use your own.

Box.Net: http://www.box.net/files
Windows Live Skydrive: http://skydrive.live.com
MediaFi http://www.mediafire.com
FileFactory: http://www.filefactory.com
FileSavr: http://www.filesavr.com
RapidSha http://www.rapidshare.com

But I suspect we cannot duplicate the problem. The problem is probably with
your computer environment. I suggest that try Office Repair. If that does
not remedy the problem, try uninstalling and reinstalling Office.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Debug.Print statement causes Excel crash

On Saturday, June 15, 2013 1:06:07 PM UTC+2, wrote:
After some search effort I found the cause for an Excel crash. Just in case you experience the same this is what I discovered: In Excel 2003, 2007 (and later?) the statement Debug.Print , "test" causes Excel to crash. There is an <empty expression in front of the comma. The crash occurs only when a piece of VBA is executed without the Visual Basic editor window opened.


I tested on a separate laptop with original installed Windows XP and Office 2003 which also caused Excel to crash. Download test Excel doc on https://skydrive.live.com/redir?resi...l7TZ9 8yLgSg0
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 829
Default Debug.Print statement causes Excel crash

wrote:
Download test Excel doc on
https://skydrive.live.com/redir?resi...l7TZ9 8yLgSg0


I overlooked the significance of the fact that it is an Auto_Open macro.

(The same error occurs when I use a Workbook_Open event macro.)

I only get the error when I open it using Excel 2007, not Excel 2003 (sp3)
and not Excel 2010.

The error goes away when I remove the leading comma in the Debug.Print list.
That is:

Debug.Print "Test"

instead of

Debug.Print , "Test"

The function of the leading comma is put "Test" at the first tabstop. I was
able to effect the same function without error with the following statement:

Debug.Print vbTab & "Test"

Does that work for you?

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Debug.Print statement causes Excel crash

On Saturday, June 15, 2013 1:06:07 PM UTC+2, wrote:
After some search effort I found the cause for an Excel crash. Just in case you experience the same this is what I discovered: In Excel 2003, 2007 (and later?) the statement Debug.Print , "test" causes Excel to crash. There is an <empty expression in front of the comma. The crash occurs only when a piece of VBA is executed without the Visual Basic editor window opened.


I'm happy that you were able to replicate the error. I posted this message because it might benefit others. Of course I found a way to avoid the error and retain the formatting for example in Debug.Print " ", <remainder
Thanks!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debug Print Mike H. Excel Programming 3 August 22nd 08 12:10 PM
Debug.Print convert vba PST Excel Programming 9 August 13th 07 06:46 PM
Excel Crash wehn print to PDF [email protected] Excel Discussion (Misc queries) 0 May 18th 06 05:53 PM
question about debug.print Gary Keramidas[_4_] Excel Programming 4 September 29th 05 01:14 AM
Debug.Print ExcelMonkey[_80_] Excel Programming 1 February 6th 04 04:04 PM


All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"