LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Excel crashing during macro (but very odd)

Hello there, I have an automatic printing macro that can be set to print to a
normal printer or print to PDF as required. I have included the relevant part
of the macro below (with comments).

In PDF mode everything functions normally (as long as I have the various
DoEvents/Wait/Sleep lines in). However, running it to go to a normal printer
causes Excel to crash when it tries to close the ActiveWorkbook (marked
below).

This problem is not new to me - I have been putting up with it for a year or
more, hence having added the WAIT etc. This has overcome it in the past, but
now it can't be solved.

It is worth noting that without the WAIT lines, in PDF mode the print
dialogue box will show that it is printing page one and then everything
freezes (including the print dialogue box). This particular problem is
currently overcome. THE PROBLEM IS IN NORMAL PRINTING MODE.

Anyone with a magic wand is most welcome to respond!
Regards, Brett

CODE AS FOLLOWS:

Workbooks.Open FileName:=pPDC, UpdateLinks:=3: Application.ScreenUpdating =
False
Application.Calculation = -4135
If EM = True Then Q50_PDF_MULTISHEET 'creates a PDF
If EM = False Then 'prints normally
Sheets("PDC 1").Visible = True: Sheets("PDC 1").Select
cnt = 1: cnt2 = 52
Do While cnt <= 15 ' prints all the valid combinations
If Cells(15, cnt2) = cnt Then
Range("BI31") = Cells(15, cnt2)
calculate
Sleep 2000: DoEvents 'otherwise Excel crashes
If TR = False Then: ActiveSheet.PrintOut From:=2, To:=2
If TR = False Then: ActiveSheet.PrintOut From:=1, To:=1
End If
cnt = cnt + 1: cnt2 = cnt2 + 2
Loop
End If
DoEvents: Application.Wait Now + TimeValue("0:0:03"): DoEvents 'otherwise
Excel crashes
ActiveWorkbook.Close savechanges:=False 'in normal print mode, Excel still
crashes on this line, but executes properly in PDF
mode''''''''''''''''''''''''''''''''
FINbk.Activate 'if the previous line is taken out then Excel will
crash on this
line (normal print only)
Range("PDC.Printed") = "Y"
printed_pdc_ok:
 
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
Macro Crashing mickey Excel Programming 3 March 19th 09 08:51 PM
Excel crashing on macro execution Keith74 Excel Programming 1 June 5th 07 04:52 PM
Help with a crashing Macro needed Tadragh1 Excel Programming 6 August 13th 05 10:46 PM
Macro crashing on different computer Grace[_3_] Excel Programming 8 July 8th 04 04:12 AM
Macro Crashing Excel ultra_xcyter[_3_] Excel Programming 0 June 28th 04 02:56 PM


All times are GMT +1. The time now is 07:16 AM.

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"