HELP!!! Need xL97 Macro Updated for 2003

Desu Nota from Columbus

Well-known Member
Joined
Mar 17, 2011
Messages
556
I found a code that forces excel to print entire workbook instead of active pages. Unfortunately I think its syntax is for an earlier version.

Please help me! I have to print hundreds of excel files to PDF; the files I have done already are incomplete because only one sheet in the workbook gets converted. Here is the Macro with the link I am using.

I am using Excel 2003, and VBA 6.5

http://www.mrexcel.com/forum/showthread.php?t=40931

The error code is in bluebelow--- Compile Error! User-Defined type not defined.


Option Explicit
Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
Application.EnableEvents = False
ActiveWorkbook.PrintOut Copies:=1, Collate:=True
Application.EnableEvents = True
Cancel = True
End Sub

-----------------------------------------------------------------------

Option Explicit

Dim AppClass As New EventClass

Private Sub Workbook_Open()
Set AppClass.App = Application

End Sub




Thank you to anyone who can help me.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Put all of this in the Thisworkbook module

Code:
Option Explicit

[COLOR="Red"]Private WithEvents App As Application

Private Sub Workbook_Open()
    Set App = Application
End Sub[/COLOR]

Private Sub App_WorkbookBeforePrint(ByVal Wb As Workbook, Cancel As Boolean)
    Application.EnableEvents = False
    ActiveWorkbook.PrintOut Copies:=1, Collate:=True
    Application.EnableEvents = True
    Cancel = True
End Sub

The part in red above replaces this (below) from your original code. No need for a separate Class module.
Code:
Option Explicit

Dim AppClass As New EventClass

Private Sub Workbook_Open()
Set AppClass.App = Application

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top