Print Current Page Only Macro

V

vschlen

I am trying to come up with a macro with the ability to print th
current page. It has become a big need within my company and will b
a real time saver. Is there a way to search for the active cell an
then print the current page it is in? In other words, by placin
your cursor on the page you want to print, you could then run th
print current page macro
 
F

Frank Kabel

Hi
SUB print_current()
ActiveSheet.PrintOut
end sub

But why don't you sue the print icon in the toolbar. AFAIK this only
prints the current selected sheet(s)

HTH
Frank
 
K

Kate G.

don't forget -- the SHEET and the CURRENT PAGE are not necessarily the
same. Some worksheets may print to 20, 30 or more pages. Defining the
print area is also a useful tool -- but needs to be reset to each different
area as needed.

Kate in MN
 
L

Leo Heuser

If I have understood you correctly, this
code will do the job.
Place the cursor in a cell and run the sub,
and the page containing the active cell
will be printed.

Sub PrintPageContainingCursor()
'Leo Heuser, 4 Feb. 2004
Dim Hpb As HPageBreak
Dim HorizPagebreak As Long
Dim NumberOfHorizPages As Long
Dim NumberOfVertiPages As Long
Dim PageNumber As Long
Dim Vpb As VPageBreak
Dim VertiPagebreak As Long

With ActiveSheet
NumberOfHorizPages = .HPageBreaks.Count + 1
NumberOfVertiPages = .VPageBreaks.Count + 1

For Each Vpb In .VPageBreaks
If Vpb.Location.Column < ActiveCell.Column Then
VertiPagebreak = VertiPagebreak + 1
End If
Next Vpb

For Each Hpb In .HPageBreaks
If Hpb.Location.Row < ActiveCell.Row Then
HorizPagebreak = HorizPagebreak + 1
End If
Next Hpb

If .PageSetup.Order = xlOverThenDown Then
PageNumber = NumberOfVertiPages * _
HorizPagebreak + VertiPagebreak + 1
Else
PageNumber = NumberOfHorizPages * _
VertiPagebreak + HorizPagebreak + 1
End If

.PrintOut , from:=PageNumber, to:=PageNumber, copies:=1
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top