+ Reply to Thread
Results 1 to 6 of 6

printpreview

  1. #1
    Alex
    Guest

    printpreview

    I'm using the following code to prevent the empty rows printing.
    Private Sub Workbook_BeforePrint(Cancel As Boolean)
    If ActiveSheet.Name = "Initiatives" Then
    Cancel = True
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    With ActiveSheet
    On Error Resume Next
    .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    True
    .PrintOut
    .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    False
    On Error GoTo 0
    End With
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    End If
    End Sub
    But, when I'm trying to use the code below to get a preprint report it's not
    working.
    ActiveWindow.SelectedSheets.PrintPreview

    Could anybody advise how I could make it's working?

    Thanks

  2. #2
    Ron de Bruin
    Guest

    Re: printpreview

    Hi Alex

    Try to disable the events

    Application.EnableEvents = False
    ActiveWindow.SelectedSheets.PrintPreview
    Application.EnableEvents = True



    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Alex" <[email protected]> wrote in message news:[email protected]...
    > I'm using the following code to prevent the empty rows printing.
    > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > If ActiveSheet.Name = "Initiatives" Then
    > Cancel = True
    > Application.EnableEvents = False
    > Application.ScreenUpdating = False
    > With ActiveSheet
    > On Error Resume Next
    > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > True
    > .PrintOut
    > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > False
    > On Error GoTo 0
    > End With
    > Application.EnableEvents = True
    > Application.ScreenUpdating = True
    > End If
    > End Sub
    > But, when I'm trying to use the code below to get a preprint report it's not
    > working.
    > ActiveWindow.SelectedSheets.PrintPreview
    >
    > Could anybody advise how I could make it's working?
    >
    > Thanks




  3. #3
    Alex
    Guest

    Re: printpreview

    Thanks a lot, Ron.
    Now, it's working.

    "Ron de Bruin" wrote:

    > Hi Alex
    >
    > Try to disable the events
    >
    > Application.EnableEvents = False
    > ActiveWindow.SelectedSheets.PrintPreview
    > Application.EnableEvents = True
    >
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "Alex" <[email protected]> wrote in message news:[email protected]...
    > > I'm using the following code to prevent the empty rows printing.
    > > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > > If ActiveSheet.Name = "Initiatives" Then
    > > Cancel = True
    > > Application.EnableEvents = False
    > > Application.ScreenUpdating = False
    > > With ActiveSheet
    > > On Error Resume Next
    > > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > > True
    > > .PrintOut
    > > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > > False
    > > On Error GoTo 0
    > > End With
    > > Application.EnableEvents = True
    > > Application.ScreenUpdating = True
    > > End If
    > > End Sub
    > > But, when I'm trying to use the code below to get a preprint report it's not
    > > working.
    > > ActiveWindow.SelectedSheets.PrintPreview
    > >
    > > Could anybody advise how I could make it's working?
    > >
    > > Thanks

    >
    >
    >


  4. #4
    Alex
    Guest

    Re: printpreview

    Sorry, Ron.
    I've reported it as done. But, now I'm getting all pages not just filled
    rows as before.
    The Private Sub Workbook_BeforePrint(Cancel As Boolean) is not working.
    (the code in the post below )

    "Ron de Bruin" wrote:

    > Hi Alex
    >
    > Try to disable the events
    >
    > Application.EnableEvents = False
    > ActiveWindow.SelectedSheets.PrintPreview
    > Application.EnableEvents = True
    >
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "Alex" <[email protected]> wrote in message news:[email protected]...
    > > I'm using the following code to prevent the empty rows printing.
    > > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > > If ActiveSheet.Name = "Initiatives" Then
    > > Cancel = True
    > > Application.EnableEvents = False
    > > Application.ScreenUpdating = False
    > > With ActiveSheet
    > > On Error Resume Next
    > > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > > True
    > > .PrintOut
    > > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > > False
    > > On Error GoTo 0
    > > End With
    > > Application.EnableEvents = True
    > > Application.ScreenUpdating = True
    > > End If
    > > End Sub
    > > But, when I'm trying to use the code below to get a preprint report it's not
    > > working.
    > > ActiveWindow.SelectedSheets.PrintPreview
    > >
    > > Could anybody advise how I could make it's working?
    > >
    > > Thanks

    >
    >
    >


  5. #5
    Ron de Bruin
    Guest

    Re: printpreview

    > I've reported it as done. But, now I'm getting all pages not just filled
    > rows as before.


    That's correct
    What did you expect

    If you only want to preview then use

    Sub test()
    With Sheets("Initiatives")
    On Error Resume Next
    .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
    .PrintPreview
    .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = False
    On Error GoTo 0
    End With
    End Sub




    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Alex" <[email protected]> wrote in message news:[email protected]...
    > Sorry, Ron.
    > I've reported it as done. But, now I'm getting all pages not just filled
    > rows as before.
    > The Private Sub Workbook_BeforePrint(Cancel As Boolean) is not working.
    > (the code in the post below )
    >
    > "Ron de Bruin" wrote:
    >
    >> Hi Alex
    >>
    >> Try to disable the events
    >>
    >> Application.EnableEvents = False
    >> ActiveWindow.SelectedSheets.PrintPreview
    >> Application.EnableEvents = True
    >>
    >>
    >>
    >> --
    >> Regards Ron de Bruin
    >> http://www.rondebruin.nl
    >>
    >>
    >> "Alex" <[email protected]> wrote in message news:[email protected]...
    >> > I'm using the following code to prevent the empty rows printing.
    >> > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    >> > If ActiveSheet.Name = "Initiatives" Then
    >> > Cancel = True
    >> > Application.EnableEvents = False
    >> > Application.ScreenUpdating = False
    >> > With ActiveSheet
    >> > On Error Resume Next
    >> > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    >> > True
    >> > .PrintOut
    >> > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    >> > False
    >> > On Error GoTo 0
    >> > End With
    >> > Application.EnableEvents = True
    >> > Application.ScreenUpdating = True
    >> > End If
    >> > End Sub
    >> > But, when I'm trying to use the code below to get a preprint report it's not
    >> > working.
    >> > ActiveWindow.SelectedSheets.PrintPreview
    >> >
    >> > Could anybody advise how I could make it's working?
    >> >
    >> > Thanks

    >>
    >>
    >>




  6. #6
    Alex
    Guest

    Re: printpreview

    Thank you very much. It's working

    "Ron de Bruin" wrote:

    > > I've reported it as done. But, now I'm getting all pages not just filled
    > > rows as before.

    >
    > That's correct
    > What did you expect
    >
    > If you only want to preview then use
    >
    > Sub test()
    > With Sheets("Initiatives")
    > On Error Resume Next
    > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
    > .PrintPreview
    > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = False
    > On Error GoTo 0
    > End With
    > End Sub
    >
    >
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "Alex" <[email protected]> wrote in message news:[email protected]...
    > > Sorry, Ron.
    > > I've reported it as done. But, now I'm getting all pages not just filled
    > > rows as before.
    > > The Private Sub Workbook_BeforePrint(Cancel As Boolean) is not working.
    > > (the code in the post below )
    > >
    > > "Ron de Bruin" wrote:
    > >
    > >> Hi Alex
    > >>
    > >> Try to disable the events
    > >>
    > >> Application.EnableEvents = False
    > >> ActiveWindow.SelectedSheets.PrintPreview
    > >> Application.EnableEvents = True
    > >>
    > >>
    > >>
    > >> --
    > >> Regards Ron de Bruin
    > >> http://www.rondebruin.nl
    > >>
    > >>
    > >> "Alex" <[email protected]> wrote in message news:[email protected]...
    > >> > I'm using the following code to prevent the empty rows printing.
    > >> > Private Sub Workbook_BeforePrint(Cancel As Boolean)
    > >> > If ActiveSheet.Name = "Initiatives" Then
    > >> > Cancel = True
    > >> > Application.EnableEvents = False
    > >> > Application.ScreenUpdating = False
    > >> > With ActiveSheet
    > >> > On Error Resume Next
    > >> > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > >> > True
    > >> > .PrintOut
    > >> > .Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden =
    > >> > False
    > >> > On Error GoTo 0
    > >> > End With
    > >> > Application.EnableEvents = True
    > >> > Application.ScreenUpdating = True
    > >> > End If
    > >> > End Sub
    > >> > But, when I'm trying to use the code below to get a preprint report it's not
    > >> > working.
    > >> > ActiveWindow.SelectedSheets.PrintPreview
    > >> >
    > >> > Could anybody advise how I could make it's working?
    > >> >
    > >> > Thanks
    > >>
    > >>
    > >>

    >
    >
    >


+ 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