Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help With code

I am having a bit of trouble with this code, it is causing a runtime error
1004, when the cancel button is hit on the input box. How can I correct the
code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True

End Sub
Thanks

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Help With code

Try

SixDigit = InputBox("How many print-outs do you want?", " ", "2")
If IsNumeric(SixDigit) Then
ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit,
Collate:=True
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg B" wrote in message
...
I am having a bit of trouble with this code, it is causing a
runtime error 1004, when the cancel button is hit on the input
box. How can I correct the code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ",
"2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit,
Collate:=True

End Sub
Thanks

Greg



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Help With code

Thanks for that

Greg
"Chip Pearson" wrote in message
...
Try

SixDigit = InputBox("How many print-outs do you want?", " ", "2")
If IsNumeric(SixDigit) Then
ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg B" wrote in message
...
I am having a bit of trouble with this code, it is causing a runtime error
1004, when the cancel button is hit on the input box. How can I correct
the code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True

End Sub
Thanks

Greg





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Help With code

Maybe this will do it (un-tested):

ActiveWindow.SelectedSheets.PrintOut Copies:=Val(Trim(SixDigit)),
Collate:=True

RBS


"Greg B" wrote in message
...
I am having a bit of trouble with this code, it is causing a runtime error
1004, when the cancel button is hit on the input box. How can I correct
the code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True

End Sub
Thanks

Greg


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help With code

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

If SixDigit < "" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True
End If



--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Greg B" wrote in message
...
I am having a bit of trouble with this code, it is causing a runtime error
1004, when the cancel button is hit on the input box. How can I correct

the
code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True

End Sub
Thanks

Greg






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Help With code

Sub test()

Greg,

I used the more complex type of inputbox which allows you to specify input
type (in this case "1" allows only numeric input).

Dim SixDigit As Long
SixDigit = Application.InputBox("How many print-outs do you want?", Type:=1,
Default:=2)
If SixDigit 0 Then
ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True
End If

End Sub

--
hth,

Doug
"Greg B" wrote in message
...
I am having a bit of trouble with this code, it is causing a runtime error
1004, when the cancel button is hit on the input box. How can I correct
the code below?

Dim SixDigit As String

SixDigit = InputBox("How many print-outs do you want?", " ", "2")

ActiveWindow.SelectedSheets.PrintOut Copies:=SixDigit, Collate:=True

End Sub
Thanks

Greg



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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 10:41 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"