+ Reply to Thread
Results 1 to 2 of 2

printing macro,want to use beforeprint event?

  1. #1
    paul
    Guest

    printing macro,want to use beforeprint event?

    below is a macro I have written/recorded.My macro skills are pretty basic(no
    pun intended!)I always start with a recorded procedure and go on from there.
    The idea of this prcedure is two fold.
    1) print only the worksheets used
    2) check that freight has been allowed on each sheet(product type)
    3)I am aware that I have not "dim" at the start but i dont undersand that
    stuff
    In my mind this could be activated by the before print event but i notice
    that the before print event is triggered evrytime the .printout call is made
    How should i call it,just a button on the sheet or toolbar?
    4)At the moment it just lives in a general module of the quote template but
    i dont really want it in every quote i do.
    Sub Macro1()
    '
    ' Macro1 Macro
    ' Macro recorded 26/06/2006 by paul
    '

    ScreenUpdating = False
    If Range("framefreight") = 0 And Range("framesell") > 0 Then
    myfrfreight = InputBox("Enter Freight for frames in hrs then ok to
    continue or cancel to exit.Enter 0 to enter no freight or cancel to exit to
    workbook", "Freight", 2)
    If myfrfreight = "" Then
    Exit Sub
    Else
    Range("framefreight") = myfrfreight
    End If
    End If
    If Range("trussfreight") = 0 And Range("trusssell") > 0 Then
    mytrfreight = InputBox("Enter Freight for trusses in hrs then ok to
    continue or cancel to exit.Enter 0 to enter no freight or cancel to exit to
    workbook", "Freight", 2)
    If mytrfreight = "" Then
    Exit Sub
    Else
    Range("trussfreight") = mytrfreight
    End If
    End If
    If Range("posifreight") = 0 And Range("posisell") > 0 Then
    mypofreight = InputBox("Enter Freight for frames in hrs then ok to
    continue or cancel to exit.Enter 0 to enter no freight or cancel to exit to
    workbook", "Freight", 2)
    If mypofreight = "" Then
    Exit Sub
    Else
    Range("posifreight") = mypofreight
    End If
    End If
    If Range("rafterfreight") = 0 And Range("raftersell") > 0 Then
    myrafreight = InputBox("Enter Freight for frames in hrs then ok to
    continue or cancel to exit.Enter 0 to enter no freight or cancel to exit to
    workbook", "Freight", 2)
    If myrafreight = "" Then
    Exit Sub
    Else
    Range("rafterfreight") = myrafreight
    End If
    End If
    Sheets("Cover").Select
    Application.Dialogs(xlDialogPrint).Show
    If Range("framesell") > 0 Then
    Sheets("Frame").PrintOut Copies:=1
    End If
    If Range("trusssell") > 0 Then
    Sheets("Truss").PrintOut Copies:=1
    Sheets("Truss Materials").PrintOut Copies:=1
    End If
    If Range("posisell") > 0 Then
    Sheets("posi").PrintOut Copies:=1
    End If
    If Range("raftersell") > 0 Then
    Sheets("Rafter").PrintOut Copies:=1
    End If
    If Range("mismattot") > 0 Then
    Sheets("mismat").PrintOut Copies:=1
    End If
    ScreenUpdating = True
    End Sub

    --
    paul
    paul.shepherd@nospamparadise.net.nz
    remove nospam for email addy!


  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525
    Quote Originally Posted by paul
    1) print only the worksheets used
    You could do something like this...

    Sheets("Select").Select
    If ActiveSheet.Range("F5").Value < 1 Then
    Sheets("two").Select
    ActiveWindow.SelectedSheets.Visible = False
    End If
    'Print three
    Sheets("Select").Select
    If ActiveSheet.Range("F6").Value < 1 Then
    Sheets("three").Select
    ActiveWindow.SelectedSheets.Visible = False
    End If

    in this example...
    if Sheet"Select"range F5 is less then 1 then Hide sheet "two"
    if Sheet"Select"range F6 is less then 1 then Hide sheet "three"
    then in your macro you could have print entire workbook and only the sheets that are visible will be printed
    in the same macro after the print command you should make sheets visible again

    Sheets("two").Visible = True
    Sheets("three").Visible = True

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1