Re: Suppress First Page Header

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Jim, me again. Thanks so much for your time I really appreciate it. I
inserted the coding you provided. I'm getting an error message in This
Workbook. The error is: Compile error: Sub or Function not defined.

The code that is highlighted is PrintTest. I've checked the coding and it
matches yours.

I wasn't sure if I was to include Option Explicit so I entered it, but with
or without it I still receive the message. Do I need to include Option
Explicit?

Thanks so much!


--
Jamie


"Jim Cone" wrote:

> Jamie,
>
> You can use the "BeforePrint" event that Excel provides.
> If you do this every sheet in the workbook will use your
> code when it is printed...
> Jim Cone
> San Francisco, USA
>
>
> In the ThisWorkbook module add the following code:
> '------------------------------
> Option Explicit
>
> Private Sub Workbook_BeforePrint(Cancel As Boolean)
> 'Prevent normal printing.
> Cancel = True
> 'Call the macro with printing code.
> PrintTest
> End Sub
> '------------------------------
> '------------------------------
>
> In a standard module add the following code...
> (your code with some additional lines)
> '-------------------------------------
> Option Explicit
>
> Sub PrintTest()
> On Error GoTo PrintError ' New line
> Application.EnableEvents = False ' New line
> Dim TotPages As Long
> TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
> With ActiveSheet.PageSetup
> .LeftHeader = ""
> ActiveSheet.PrintOut From:=1, To:=1
> .LeftHeader = "Unit Intake Report (continued)"
> ActiveSheet.PrintOut From:=2, To:=TotPages
> End With
> PrintError: ' New line
> Application.EnableEvents = True ' New line
> End Sub
> '------------------------------------
> '------------------------------------
>
>
> "Jamie" <Jamie@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:AB93B194-919C-4BDC-8CA9-3649589A19A3@xxxxxxxxxxxxxxxx
> > Hi Jim, thanks for your help. I have another question. Can I add coding
> > to the macro so the user can either use the print button or File, Print.
> > I'd like to keep them out of Tools, Macro, Macros. Also I'd like to stay
> > away from creating a print button on the worksheet.
> > Jamie
>
>
>
> > "Jim Cone" wrote:
> > > Jamie,
> > > You are welcome.
> > > A way to start the macro from the worksheet is to
> > > go to the menu bar...
> > > Tools | Macro | Macros...
> > > In the displayed list of macros,
> > > select your macro and click the "Run" button.
> > > Regards,
> > > Jim Cone
> > > San Francisco, USA
>
> -snip-
>
.



Relevant Pages

  • Re: Suppress First Page Header
    ... Private Sub Workbook_BeforePrint ... 'Call the macro with printing code. ... > Hi Jim, thanks for your help. ... >> Jamie, ...
    (microsoft.public.excel.programming)
  • Re: Handling Errors and MessageBox
    ... Thanks for the reply Jim. ... > false so that the sub can not be run until data is retrieved. ... > can create the pivot with your sub. ... >> data base and by running the Macro a second time. ...
    (microsoft.public.excel.programming)
  • Re: Need help converting macro from 2002 to 2007
    ... Thanks Jim that worked. ... as the second line after Sub Work_Paper ... | This is a macro that one of our ex-employees created in excel 2002. ... | Selection.ShapeRange.Fill.Visible = msoTrue ...
    (microsoft.public.excel.programming)
  • Re: Change links to hyperlinks in a workbook?
    ... Thanks Jim, but the macro gave me a syntax error. ... You could try this macro I just threw together. ... > Sub MakeHyperLinks() ... > For Each Cell In Selection.SpecialCells ...
    (microsoft.public.excel.misc)
  • Re: Mailmerge issue
    ... The problem could be caused by an error in your coding earlier on. ... What's the the code for rest of this sub? ... There is macro defined in one of the word document. ... under preferences and saw that microsoft word lib is checked. ...
    (microsoft.public.word.mailmerge.fields)