View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
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