Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default printing macro problem

The following macro is supposed to define and print a range listed in
cell F95 on a worksheet designated as "admin". Sometimes, the macro
prints the defined range, but other times, the macro prints the entire
worksheet (over ten pages). I cannot figure out why the bahavior is
sporadic. Any thoughts or solutions would be greatly appreciated.

Here's the macro:

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=INDIRECT(admin!F95)"
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

------------

Incidentally, "admin!F95" contains the following:

=CONCATENATE("'Schedule 1'!$A$1:",D95)

and...

D95 contains a variable: (e.g. $AP$30)

So, the text string in F95 is currently: 'Schedule 1'!$A$1:$AP$30

Thanks kindly.

Joseph

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default printing macro problem

I don't see any role for Indirect he

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=" & worksheets("Admin").Range("F95").Value
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

--
Regards,
Tom Ogilvy

" wrote:

The following macro is supposed to define and print a range listed in
cell F95 on a worksheet designated as "admin". Sometimes, the macro
prints the defined range, but other times, the macro prints the entire
worksheet (over ten pages). I cannot figure out why the bahavior is
sporadic. Any thoughts or solutions would be greatly appreciated.

Here's the macro:

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=INDIRECT(admin!F95)"
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

------------

Incidentally, "admin!F95" contains the following:

=CONCATENATE("'Schedule 1'!$A$1:",D95)

and...

D95 contains a variable: (e.g. $AP$30)

So, the text string in F95 is currently: 'Schedule 1'!$A$1:$AP$30

Thanks kindly.

Joseph


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default printing macro problem

Thanks much, Tom. I haven't tested it, but I will tonight at my
office.

I'm not sure I understand why Indirect isn't used to ensure the
concatenated text string is treated as a reference to a cell. I will
try to read more about that function and cell referencing this evening.

As always, thanks again for your assistance. I always learn a lot here
from you and others.

Joseph


Tom Ogilvy wrote:
I don't see any role for Indirect he

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=" & worksheets("Admin").Range("F95").Value
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

--
Regards,
Tom Ogilvy

" wrote:

The following macro is supposed to define and print a range listed in
cell F95 on a worksheet designated as "admin". Sometimes, the macro
prints the defined range, but other times, the macro prints the entire
worksheet (over ten pages). I cannot figure out why the bahavior is
sporadic. Any thoughts or solutions would be greatly appreciated.

Here's the macro:

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=INDIRECT(admin!F95)"
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

------------

Incidentally, "admin!F95" contains the following:

=CONCATENATE("'Schedule 1'!$A$1:",D95)

and...

D95 contains a variable: (e.g. $AP$30)

So, the text string in F95 is currently: 'Schedule 1'!$A$1:$AP$30

Thanks kindly.

Joseph



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default printing macro problem

Tom,

Your solution worked flawlessly. However, when I copied the workbook
(along with the macro) to another workbook in the same directory, I am
receiving an error (code 13) for this part of the macro:

ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=" & worksheets("Admin").Range("F95").Value

For example:

The macro in this workbook works ------ c:\test\test.excel
The copied macro in this workbook fails ------ c:\test\copy of
test.excel

Any thoughts or suggestions?

Thanks!

Joseph

Tom Ogilvy wrote:
I don't see any role for Indirect he

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=" & worksheets("Admin").Range("F95").Value
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

--
Regards,
Tom Ogilvy

" wrote:

The following macro is supposed to define and print a range listed in
cell F95 on a worksheet designated as "admin". Sometimes, the macro
prints the defined range, but other times, the macro prints the entire
worksheet (over ten pages). I cannot figure out why the bahavior is
sporadic. Any thoughts or solutions would be greatly appreciated.

Here's the macro:

Sub print_schedule()
'
' print_schedule Macro
'

'
Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets("Schedule 1").Select
ActiveWorkbook.Names.Add Name:= _
"'Schedule 1'!Print_Area", _
RefersTo:="=INDIRECT(admin!F95)"
Application.ActivePrinter = "\\Print01\ARPRN41 on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Sheets("Personnel").Select

Application.ScreenUpdating = True
Application.DisplayAlerts = True

End Sub

------------

Incidentally, "admin!F95" contains the following:

=CONCATENATE("'Schedule 1'!$A$1:",D95)

and...

D95 contains a variable: (e.g. $AP$30)

So, the text string in F95 is currently: 'Schedule 1'!$A$1:$AP$30

Thanks kindly.

Joseph



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default printing macro problem

Edit:

For example:

The macro in this workbook works ------ c:\test\test.excel
The copied macro in this workbook fails ------ c:\test\copy of
test.excel


Sorry, that should say:

For example:

The macro in this workbook works ------ c:\test\test.xls
The copied macro in this workbook fails ------ c:\test\copy of
test.xls

-----------------

I've been up for 36 hours. Time for sleep.

Joseph



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
Printing Problem Ksean Excel Discussion (Misc queries) 0 April 8th 10 05:26 PM
Excel 2003 printing problem--printing 1 document on 2 pages Bons Excel Discussion (Misc queries) 0 December 24th 09 04:15 PM
Printing problem FiluDlidu Excel Discussion (Misc queries) 6 April 1st 08 12:09 AM
Printing Problem In Excel Due to Macro? [email protected] Excel Discussion (Misc queries) 4 March 20th 07 04:05 PM
Excel printing macro problem Cam[_6_] Excel Programming 2 February 18th 06 03:48 PM


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

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"