Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Need Macro to print curent page only

I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Need Macro to print curent page only

Not sure about the current page, but in the PrintOut arguments you can
specify the From and To page numbers, so if your current page is 3 the
From:=3. To:=3 should do it.

"Don Lowe" wrote:

I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Need Macro to print curent page only

I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).

"JLGWhiz" wrote:

Not sure about the current page, but in the PrintOut arguments you can
specify the From and To page numbers, so if your current page is 3 the
From:=3. To:=3 should do it.

"Don Lowe" wrote:

I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Need Macro to print curent page only

i know what you want - Word has "print current page" & i've often
wished Excel had the same thing.
i've done it on a small scale by hard-coding the row #s, such as this
(draft coding):
===========================
if activecell.row = 103 and
if activecell.row <= 135 then
print From:=3. To:=3 'i don't know the print
'structure off the top
'of my head
if activecell.row = 203 and
if activecell.row <= 235 then
print From:=5. To:=5
===========================
that type of thing........... or could make it a case statement
structure.
caveat - it will only work if no additional rows will be added in the
future, but it can be done.........
hope this helps.
susan


On May 6, 2:32*pm, Don Lowe wrote:
I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).



"JLGWhiz" wrote:
Not sure about the current page, but in the PrintOut arguments you can
specify the From and To page numbers, so if your current page is 3 the
From:=3. To:=3 should do it.


"Don Lowe" wrote:


I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Need Macro to print curent page only

Hi Don. Have a look at Allen Wyatt's solution. This code simply
places the page number in a message box, but you could easily change
this to return the page number to use in a print statement.
http://exceltips.vitalnews.com/Pages...rs_in_VBA.html

On May 6, 2:32*pm, Don Lowe wrote:
I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).



"JLGWhiz" wrote:
Not sure about the current page, but in the PrintOut arguments you can
specify the From and To page numbers, so if your current page is 3 the
From:=3. To:=3 should do it.


"Don Lowe" wrote:


I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Need Macro to print curent page only

Don, here is a quickly tweaked version of Allen's code. Just turned
it into a function and added a few things here and there and got rid
of the old Excel4 macro. To use it, just call the printpage the
procedure below it. Keep in mind, there is no error handling in this
procedure. Feel free to add that in if you see fit.

Function PageInfo(currCell As Range)
Dim iPages As Integer
Dim iCol As Integer
Dim iCols As Integer
Dim lRows As Long
Dim lRow As Long
Dim x As Long
Dim y As Long
Dim hBreaks As Long
Dim vBreaks As Long
Application.ScreenUpdating = False
ActiveWindow.View = xlPageBreakPreview
hBreaks = Worksheets(1).HPageBreaks.Count
vBreaks = Worksheets(1).VPageBreaks.Count
iPages = (hBreaks + 1) * (vBreaks + 1)
With ActiveSheet
y = currCell.Column
iCols = .VPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = iCols _
Or y < .VPageBreaks(x).Location.Column
iCol = x
If y = .VPageBreaks(x).Location.Column Then
iCol = iCol + 1
End If
y = ActiveCell.Row
lRows = .HPageBreaks.Count
x = 0
Do
x = x + 1
Loop Until x = lRows _
Or y < .HPageBreaks(x).Location.Row
lRow = x
If y = .HPageBreaks(x).Location.Row Then
lRow = lRow + 1
End If
If .PageSetup.Order = xlDownThenOver Then
PageInfo = (iCol - 1) * (lRows + 1) + lRow
Else
PageInfo = (lRow - 1) * (iCols + 1) + iCol
End If
End With
Application.ScreenUpdating = True
ActiveWindow.View = xlNormalView
End Function

Sub printpage()
Dim p As Long
p = PageInfo(ActiveCell)
ActiveSheet.PrintOut From:=p, To:=p
End Sub

On May 7, 9:00*am, JW wrote:
Hi Don. *Have a look at Allen Wyatt's solution. *This code simply
places the page number in a message box, but you could easily change
this to return the page number to use in a print statement.http://exceltips.vitalnews.com/Pages...rs_in_VBA.html

On May 6, 2:32*pm, Don Lowe wrote:



I am hoping to have a macro that looks at what pape I am on and will print
the specific page. This way I do not need to make 97 buttons for printing.
One button printing where ever you are (most of my users would not now where
they are and I am trying to make this really really easy for them).


"JLGWhiz" wrote:
Not sure about the current page, but in the PrintOut arguments you can
specify the From and To page numbers, so if your current page is 3 the
From:=3. To:=3 should do it.


"Don Lowe" wrote:


I have many people using the file. Each person only needs a page worth of
information. I need a Macro to print curent page only.- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Need Macro to print curent page only

JW,

I have tried the code you gave me. I continue to get "Run-Time Error 9".
Then I can not get it to work when I go to debug the highlighted area:

Loop Until x = iCols _
Or y < .VPageBreaks(x).Location.Column

What am I doing wrong?


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default Need Macro to print curent page only

On May 12, 2:59*pm, Don Lowe
wrote:
JW,

I have tried the code you gave me. I continue to get "Run-Time Error 9".
Then I can not get it to work when I go to debug the highlighted area:

Loop Until x = iCols _
* * * * * * Or y < .VPageBreaks(x).Location.Column

What am I doing wrong?


Not sure. Works just fine for me here. What version of Excel are you
running (I'm running 97 and 2003)? You can send me your workbook
containing the code and I will take a look at it.
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Need Macro to print curent page only

JW,

I am using Excel 2003. What is your e-mail? I will send you the workbook.


"JW" wrote:

On May 12, 2:59 pm, Don Lowe
wrote:
JW,

I have tried the code you gave me. I continue to get "Run-Time Error 9".
Then I can not get it to work when I go to debug the highlighted area:

Loop Until x = iCols _
Or y < .VPageBreaks(x).Location.Column

What am I doing wrong?


Not sure. Works just fine for me here. What version of Excel are you
running (I'm running 97 and 2003)? You can send me your workbook
containing the code and I will take a look at it.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a macro to print a page? Matt Excel Discussion (Misc queries) 2 May 14th 09 09:46 PM
Setting the print area in page set up to print 1 page wide by 2 pages tall EA[_2_] Excel Discussion (Misc queries) 2 July 12th 07 08:39 PM
Macro for Print Odd and Even page emil Excel Programming 2 May 2nd 06 09:04 PM
Macro to print web page and close browser Oreg[_61_] Excel Programming 6 April 8th 06 11:29 AM
Excel Print Page setup macro... hord Excel Programming 0 January 22nd 04 01:01 AM


All times are GMT +1. The time now is 05:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"