ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   PrintPreview Question (https://www.excelbanter.com/excel-programming/316539-printpreview-question.html)

JimP

PrintPreview Question
 
To All,

I'm using the following Function:

What I'm questioning, is - Is there a way to initiate a PrintPreview
at a specific start page?

My First attempt allows Specific pages to be printed, but PrintPreview
ALWAYS initiates from Page 1

My Second attempt, I tried to Set .FirstPageNumber in PageSetup prior
to calling PrintPreview ... but it does nothing?

Any thoughts on how I can improve this Function?
Thanks in advance for any assistance,

JimP

'''''''1st attempt''''''''''''''''''''''''''''
Function PageToPrintOrView(iStart As Integer, iFinish As Integer, _
iPrintOrView As Integer)
'------------------------------------------
' Routine receives:
' PRINT Page Start#,
' PRINT Page Finish#, and
' PrintOrView: 0 = SEND TO PRINTER ... 1 = Print PREVIEW
indicator
'------------------------------------------
ActiveSheet.Select
If iPrintOrView Then
ActiveWindow.SelectedSheets.PrintPreview ' PREVIEW
Else
ActiveWindow.SelectedSheets.PrintOut From:=iStart, To:=iFinish,
_
Copies:=1, Collate:=True ' PRINT
End If
Range("A1").Select
End Function


''''''''2nd attempt''''''''''''''''''''''''''''''''''''
Function PageToPrintOrView(iStart As Integer, iFinish As Integer, _
iPrintOrView As Integer)
'------------------------------------------
' Routine receives:
' PRINT Page Start#,
' PRINT Page Finish#, and
' PrintOrView: 0 = SEND TO PRINTER ... 1 = Print PREVIEW
indicator
'------------------------------------------
ActiveSheet.Select
If iPrintOrView Then
' Try to Set .FirstPageNumber in PageSetup in PageSetup
With ActiveSheet.PageSetup
.FirstPageNumber = iStart
End With
ActiveWindow.SelectedSheets.PrintPreview ' PREVIEW
' Reset .FirstPageNumber in PageSetup
With ActiveSheet.PageSetup
.FirstPageNumber = xlAutomatic
End With
Else
ActiveWindow.SelectedSheets.PrintOut From:=iStart, To:=iFinish,
_
Copies:=1, Collate:=True ' PRINT
End If
Range("A1").Select
End Function

JE McGimpsey

PrintPreview Question
 
This works for me. You should be able to modify it:

Dim wsSheet As Worksheet
For Each wsSheet In ActiveWindow.SelectedSheets
wsSheet.PrintOut From:=3, To:=5, Preview:=True
Next wsSheet


In article ,
(JimP) wrote:

What I'm questioning, is - Is there a way to initiate a PrintPreview
at a specific start page?


microsoft.public.excel.programming[_3_]

PrintPreview Question
 
JE,
AWESOME!!!! Sooo simply to modify and WORKS EXACTLY AS I hoped it could
... ELEGANT!!!! Thanks ...

Jim Pellechi

Function PageToPrintOrView(iStart As Integer, iFinish As _
Integer, iPrintOrView As Integer)
' Routine receives:
' iStart Value: Start Page #
' iFinish Value: Finish Page #
' iPrintOrView Value: 0 = Print / 1 = PrintPreview
ActiveSheet.Select
With ActiveSheet
.PrintOut From:=iStart, To:=iFinish, _
Preview:=iPrintOrView, Copies:=1, Collate:=True
End With
End Function


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 02:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com