Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Print Selection in Code

When a user prints my report, I need to only print a
certain range. This is the code I used for the print
command button. It is supposed to display an input box to
input the no. of copies, then only print out the
selection that is in the code. When I run this code, I
get a run-time error '438 (Object doesn't support this
property or method.),if you click end on this error, the
report prints out fine, you click "Debug", you get this.
Run-time error'-2147417878(80010108). Automation error
The object invoked has disconnected from it's clients,
excel locks up recovers my document, sends an error
report and closes. Does anyone have a fix or a better way
to print just that range? Please help. Here is my code.

Private Sub cmdPrintAtt_Click()
Dim NoCopies As String
Dim Message, Title, Default, MyValue
Message = "How many copies?" ' Set prompt.
Title = "Print" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
NoCopies = InputBox(Message, Title, Default)
Range("A1:AH1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PrintOut Copies:=NoCopies
End Sub

TIA,
Donna Brooks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Print Selection in Code

I can't replicate the problem, but perhaps using the range object
directly rather than the Selection object will solve it:

Private Sub cmdPrintAtt_Click()
Const MESSAGE As String = "How many copies?"
Const TITLE As String = "Print"
Const DEFAULT As Integer = 1
Dim NoCopies As String
NoCopies = InputBox(MESSAGE, TITLE, DEFAULT)
With Range("A1:AH1")
Range(.Cells, .Cells.End(xlDown)).PrintOut _
Copies:=NoCopies
End With
End Sub


In article ,
"Donna Brooks" wrote:

When a user prints my report, I need to only print a
certain range. This is the code I used for the print
command button. It is supposed to display an input box to
input the no. of copies, then only print out the
selection that is in the code. When I run this code, I
get a run-time error '438 (Object doesn't support this
property or method.),if you click end on this error, the
report prints out fine, you click "Debug", you get this.
Run-time error'-2147417878(80010108). Automation error
The object invoked has disconnected from it's clients,
excel locks up recovers my document, sends an error
report and closes. Does anyone have a fix or a better way
to print just that range? Please help. Here is my code.

Private Sub cmdPrintAtt_Click()
Dim NoCopies As String
Dim Message, Title, Default, MyValue
Message = "How many copies?" ' Set prompt.
Title = "Print" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
NoCopies = InputBox(Message, Title, Default)
Range("A1:AH1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PrintOut Copies:=NoCopies
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Print Selection in Code

Change the takefocusonclick in the properties of the button
to false and it is working(Bug in 97)


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"Donna Brooks" wrote in message ...
When a user prints my report, I need to only print a
certain range. This is the code I used for the print
command button. It is supposed to display an input box to
input the no. of copies, then only print out the
selection that is in the code. When I run this code, I
get a run-time error '438 (Object doesn't support this
property or method.),if you click end on this error, the
report prints out fine, you click "Debug", you get this.
Run-time error'-2147417878(80010108). Automation error
The object invoked has disconnected from it's clients,
excel locks up recovers my document, sends an error
report and closes. Does anyone have a fix or a better way
to print just that range? Please help. Here is my code.

Private Sub cmdPrintAtt_Click()
Dim NoCopies As String
Dim Message, Title, Default, MyValue
Message = "How many copies?" ' Set prompt.
Title = "Print" ' Set title.
Default = "1" ' Set default.
' Display message, title, and default value.
NoCopies = InputBox(Message, Title, Default)
Range("A1:AH1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PrintOut Copies:=NoCopies
End Sub

TIA,
Donna Brooks



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
VBA Code User Range Selection jimbo Excel Discussion (Misc queries) 5 January 5th 10 02:31 AM
cell selection code NDBC Excel Discussion (Misc queries) 6 August 11th 09 06:39 AM
TIP: Dynamic chart selection without code Dermot Charts and Charting in Excel 0 August 11th 06 08:23 AM
How can I print frozen panes to appear above print selection in Ex Snr Franco Excel Discussion (Misc queries) 1 April 2nd 06 03:06 PM
Running code on a drop down selection change Steve Haack Excel Worksheet Functions 1 April 26th 05 05:03 AM


All times are GMT +1. The time now is 11:07 PM.

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

About Us

"It's about Microsoft Excel"