Print Selection

  • Thread starter Thread starter MikeF
  • Start date Start date
M

MikeF

Hello,

The same range needs to be printed for one or sometimes more sheets in a
workbook.
This *should* be easy, but can't seem to make it happen properly.

Can anyone please correct the following code apppropriatlely?
Thanx in advance.
- Mike


Sub PrintDetail()
Range("B7:Y40").Select
For Each Sh In ActiveWindow.SelectedSheets
Sh.PageSetup.PrintTitleRows = "$1:$6"
Sh.Selection.PrintOut Collate:=True
Next
Next
End Sub
 
Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").PrintOut
Next
End Sub


--
Jim
|
| Hello,
|
| The same range needs to be printed for one or sometimes more sheets in a
| workbook.
| This *should* be easy, but can't seem to make it happen properly.
|
| Can anyone please correct the following code apppropriatlely?
| Thanx in advance.
| - Mike
|
|
| Sub PrintDetail()
| Range("B7:Y40").Select
| For Each Sh In ActiveWindow.SelectedSheets
| Sh.PageSetup.PrintTitleRows = "$1:$6"
| Sh.Selection.PrintOut Collate:=True
| Next
| Next
| End Sub
|
 
Try this...

Sub PrintDetail()
'Range("B7:Y40").Select
For Each Sh In ActiveWindow.SelectedSheets
Sh.PageSetup.PrintTitleRows = "$1:$6"
Sh.Range("B7:Y40").PrintOut Collate:=True
'Next
Next
End Sub
 
Jim,

Thank you, this works.

Except [asking for the world here <g>] --- It prints each sheet separately.
Example - when printing three sheets, the footer on each says Page 1 of 1,
as opposed to Page 1 of 3/etc.
Is there any way to fix that?

- Mike
 
Jim,

Thank you, this works.

Except [asking for the world here <g>] --- It prints each sheet separately.
Example - when printing three sheets, the footer on each says Page 1 of 1,
as opposed to Page 1 of 3/etc.
Is there any way to fix that?

- Mike
 
Good point. But the problem is - to print them as one job they have to have
"PrintArea" defined on all sheets. Easy to do with a macro but you have to
remember that it's set and will affect manual prints of these sheets. Of
course you can expand the macro to reset the print area.<g>

Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub


--
Jim
| Jim,
|
| Thank you, this works.
|
| Except [asking for the world here <g>] --- It prints each sheet
separately.
| Example - when printing three sheets, the footer on each says Page 1 of 1,
| as opposed to Page 1 of 3/etc.
| Is there any way to fix that?
|
| - Mike
|
| "Jim Rech" wrote:
|
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").PrintOut
| > Next
| > End Sub
| >
| >
| > --
| > Jim
| > | > |
| > | Hello,
| > |
| > | The same range needs to be printed for one or sometimes more sheets in
a
| > | workbook.
| > | This *should* be easy, but can't seem to make it happen properly.
| > |
| > | Can anyone please correct the following code apppropriatlely?
| > | Thanx in advance.
| > | - Mike
| > |
| > |
| > | Sub PrintDetail()
| > | Range("B7:Y40").Select
| > | For Each Sh In ActiveWindow.SelectedSheets
| > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | Sh.Selection.PrintOut Collate:=True
| > | Next
| > | Next
| > | End Sub
| > |
| >
| >
| >
 
Jim,
Thanx, but it stalls.
Doesn't seem to like the "name" syntax is the best I can assess.
- Mike
 
Runs here. Check for a typo.

--
Jim
|
| Jim,
| Thanx, but it stalls.
| Doesn't seem to like the "name" syntax is the best I can assess.
| - Mike
|
| "Jim Rech" wrote:
|
| > Good point. But the problem is - to print them as one job they have to
have
| > "PrintArea" defined on all sheets. Easy to do with a macro but you have
to
| > remember that it's set and will affect manual prints of these sheets.
Of
| > course you can expand the macro to reset the print area.<g>
| >
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
| > Next
| > ActiveWindow.SelectedSheets.PrintOut
| > End Sub
| >
| >
| > --
| > Jim
| > | > | Jim,
| > |
| > | Thank you, this works.
| > |
| > | Except [asking for the world here <g>] --- It prints each sheet
| > separately.
| > | Example - when printing three sheets, the footer on each says Page 1
of 1,
| > | as opposed to Page 1 of 3/etc.
| > | Is there any way to fix that?
| > |
| > | - Mike
| > |
| > | "Jim Rech" wrote:
| > |
| > | > Sub PrintEm()
| > | > Dim WS As Worksheet
| > | > For Each WS In ActiveWindow.SelectedSheets
| > | > WS.Range("B7:Y40").PrintOut
| > | > Next
| > | > End Sub
| > | >
| > | >
| > | > --
| > | > Jim
| > | > | > | > |
| > | > | Hello,
| > | > |
| > | > | The same range needs to be printed for one or sometimes more
sheets in
| > a
| > | > | workbook.
| > | > | This *should* be easy, but can't seem to make it happen properly.
| > | > |
| > | > | Can anyone please correct the following code apppropriatlely?
| > | > | Thanx in advance.
| > | > | - Mike
| > | > |
| > | > |
| > | > | Sub PrintDetail()
| > | > | Range("B7:Y40").Select
| > | > | For Each Sh In ActiveWindow.SelectedSheets
| > | > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | > | Sh.Selection.PrintOut Collate:=True
| > | > | Next
| > | > | Next
| > | > | End Sub
| > | > |
| > | >
| > | >
| > | >
| >
| >
| >
 
Sometimes, you have to surround the worksheet name with apostrophes.

I'd try:

WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!PrintArea"
or combining the last two strings into one:
WS.Range("B7:Y40").Name = "'" & WS.Name & "'!PrintArea"

Jim,
Thanx, but it stalls.
Doesn't seem to like the "name" syntax is the best I can assess.
- Mike

Jim Rech said:
Good point. But the problem is - to print them as one job they have to have
"PrintArea" defined on all sheets. Easy to do with a macro but you have to
remember that it's set and will affect manual prints of these sheets. Of
course you can expand the macro to reset the print area.<g>

Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub


--
Jim
| Jim,
|
| Thank you, this works.
|
| Except [asking for the world here <g>] --- It prints each sheet
separately.
| Example - when printing three sheets, the footer on each says Page 1 of 1,
| as opposed to Page 1 of 3/etc.
| Is there any way to fix that?
|
| - Mike
|
| "Jim Rech" wrote:
|
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").PrintOut
| > Next
| > End Sub
| >
| >
| > --
| > Jim
| > | > |
| > | Hello,
| > |
| > | The same range needs to be printed for one or sometimes more sheets in
a
| > | workbook.
| > | This *should* be easy, but can't seem to make it happen properly.
| > |
| > | Can anyone please correct the following code apppropriatlely?
| > | Thanx in advance.
| > | - Mike
| > |
| > |
| > | Sub PrintDetail()
| > | Range("B7:Y40").Select
| > | For Each Sh In ActiveWindow.SelectedSheets
| > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | Sh.Selection.PrintOut Collate:=True
| > | Next
| > | Next
| > | End Sub
| > |
| >
| >
| >
 
Dave,
Thanx, this worked.
Except [<g>] --- The print range is moot --- sub-routine considers only the
pre-defined print area for each sheet.
That having been said ... is there anyway to pre-define each sheet's print
area - *all of them the same!* - in the first part of the code?

- Mike

Dave Peterson said:
Sometimes, you have to surround the worksheet name with apostrophes.

I'd try:

WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!PrintArea"
or combining the last two strings into one:
WS.Range("B7:Y40").Name = "'" & WS.Name & "'!PrintArea"

Jim,
Thanx, but it stalls.
Doesn't seem to like the "name" syntax is the best I can assess.
- Mike

Jim Rech said:
Good point. But the problem is - to print them as one job they have to have
"PrintArea" defined on all sheets. Easy to do with a macro but you have to
remember that it's set and will affect manual prints of these sheets. Of
course you can expand the macro to reset the print area.<g>

Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub


--
Jim
| Jim,
|
| Thank you, this works.
|
| Except [asking for the world here <g>] --- It prints each sheet
separately.
| Example - when printing three sheets, the footer on each says Page 1 of 1,
| as opposed to Page 1 of 3/etc.
| Is there any way to fix that?
|
| - Mike
|
| "Jim Rech" wrote:
|
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").PrintOut
| > Next
| > End Sub
| >
| >
| > --
| > Jim
| > | > |
| > | Hello,
| > |
| > | The same range needs to be printed for one or sometimes more sheets in
a
| > | workbook.
| > | This *should* be easy, but can't seem to make it happen properly.
| > |
| > | Can anyone please correct the following code apppropriatlely?
| > | Thanx in advance.
| > | - Mike
| > |
| > |
| > | Sub PrintDetail()
| > | Range("B7:Y40").Select
| > | For Each Sh In ActiveWindow.SelectedSheets
| > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | Sh.Selection.PrintOut Collate:=True
| > | Next
| > | Next
| > | End Sub
| > |
| >
| >
| >
 
WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!Print_Area"

I didn't notice the typo.
Dave,
Thanx, this worked.
Except [<g>] --- The print range is moot --- sub-routine considers only the
pre-defined print area for each sheet.
That having been said ... is there anyway to pre-define each sheet's print
area - *all of them the same!* - in the first part of the code?

- Mike

Dave Peterson said:
Sometimes, you have to surround the worksheet name with apostrophes.

I'd try:

WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!PrintArea"
or combining the last two strings into one:
WS.Range("B7:Y40").Name = "'" & WS.Name & "'!PrintArea"

Jim,
Thanx, but it stalls.
Doesn't seem to like the "name" syntax is the best I can assess.
- Mike

:

Good point. But the problem is - to print them as one job they have to have
"PrintArea" defined on all sheets. Easy to do with a macro but you have to
remember that it's set and will affect manual prints of these sheets. Of
course you can expand the macro to reset the print area.<g>

Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub


--
Jim
| Jim,
|
| Thank you, this works.
|
| Except [asking for the world here <g>] --- It prints each sheet
separately.
| Example - when printing three sheets, the footer on each says Page 1 of 1,
| as opposed to Page 1 of 3/etc.
| Is there any way to fix that?
|
| - Mike
|
| "Jim Rech" wrote:
|
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").PrintOut
| > Next
| > End Sub
| >
| >
| > --
| > Jim
| > | > |
| > | Hello,
| > |
| > | The same range needs to be printed for one or sometimes more sheets in
a
| > | workbook.
| > | This *should* be easy, but can't seem to make it happen properly.
| > |
| > | Can anyone please correct the following code apppropriatlely?
| > | Thanx in advance.
| > | - Mike
| > |
| > |
| > | Sub PrintDetail()
| > | Range("B7:Y40").Select
| > | For Each Sh In ActiveWindow.SelectedSheets
| > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | Sh.Selection.PrintOut Collate:=True
| > | Next
| > | Next
| > | End Sub
| > |
| >
| >
| >
 
Dave,
Juggled a few things on my own, and as follows is the code that works for
what I need.
Thanx for all your assistance.
- Mike

Sub PrintDetail()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.PageSetup.PrintArea = ("B7:i22")
WS.PageSetup.PrintTitleRows = "$1:$6"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub



Dave Peterson said:
WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!Print_Area"

I didn't notice the typo.
Dave,
Thanx, this worked.
Except [<g>] --- The print range is moot --- sub-routine considers only the
pre-defined print area for each sheet.
That having been said ... is there anyway to pre-define each sheet's print
area - *all of them the same!* - in the first part of the code?

- Mike

Dave Peterson said:
Sometimes, you have to surround the worksheet name with apostrophes.

I'd try:

WS.Range("B7:Y40").Name = "'" & WS.Name & "'" & "!PrintArea"
or combining the last two strings into one:
WS.Range("B7:Y40").Name = "'" & WS.Name & "'!PrintArea"


MikeF wrote:

Jim,
Thanx, but it stalls.
Doesn't seem to like the "name" syntax is the best I can assess.
- Mike

:

Good point. But the problem is - to print them as one job they have to have
"PrintArea" defined on all sheets. Easy to do with a macro but you have to
remember that it's set and will affect manual prints of these sheets. Of
course you can expand the macro to reset the print area.<g>

Sub PrintEm()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.Range("B7:Y40").Name = WS.Name & "!PrintArea"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub


--
Jim
| Jim,
|
| Thank you, this works.
|
| Except [asking for the world here <g>] --- It prints each sheet
separately.
| Example - when printing three sheets, the footer on each says Page 1 of 1,
| as opposed to Page 1 of 3/etc.
| Is there any way to fix that?
|
| - Mike
|
| "Jim Rech" wrote:
|
| > Sub PrintEm()
| > Dim WS As Worksheet
| > For Each WS In ActiveWindow.SelectedSheets
| > WS.Range("B7:Y40").PrintOut
| > Next
| > End Sub
| >
| >
| > --
| > Jim
| > | > |
| > | Hello,
| > |
| > | The same range needs to be printed for one or sometimes more sheets in
a
| > | workbook.
| > | This *should* be easy, but can't seem to make it happen properly.
| > |
| > | Can anyone please correct the following code apppropriatlely?
| > | Thanx in advance.
| > | - Mike
| > |
| > |
| > | Sub PrintDetail()
| > | Range("B7:Y40").Select
| > | For Each Sh In ActiveWindow.SelectedSheets
| > | Sh.PageSetup.PrintTitleRows = "$1:$6"
| > | Sh.Selection.PrintOut Collate:=True
| > | Next
| > | Next
| > | End Sub
| > |
| >
| >
| >
 
Jim,
Juggled a few things on my own, and as follows is the code that works for
what I need.
Thanx for all your assistance.
- Mike

Sub PrintDetail()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.PageSetup.PrintArea = ("B7:i22")
WS.PageSetup.PrintTitleRows = "$1:$6"
Next
ActiveWindow.SelectedSheets.PrintOut
End Sub
 
Jim,
Juggled a few things on my own, and as follows is the code that works for
what I need.
Thanx for all your assistance.
- Mike

Sub PrintDetail()
Dim WS As Worksheet
For Each WS In ActiveWindow.SelectedSheets
WS.PageSetup.PrintArea = ("B7:i22")
WS.PageSetup.PrintTitleRows = "$1:$6"
Next
ActiveWindow.SelectedSheets.PrintOut
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

Back
Top