Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro Crashing | Excel Programming | |||
Excel crashing on macro execution | Excel Programming | |||
Help with a crashing Macro needed | Excel Programming | |||
Macro crashing on different computer | Excel Programming | |||
Macro Crashing Excel | Excel Programming |