Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me macro Excel problem

Status
Not open for further replies.

Thecapri1

Technical User
Aug 5, 2008
4
CA
Hello sorry to ask you this but i have pass a week to search on the internet and I am not able to find my problem

Here the macro

Private Sub CommandButton1_Click()
ActiveSheet.PageSetup.PrintArea = "$a$1:$h$60"
bResponse = Application.Dialogs(xlDialogPrinterSetup).Show
If TypeName(response) = "Boolean" Then Exit Sub
ActiveSheet.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "$a$1:$AA$60"

End Sub

What is I am trying to do is creating a button call Print that will print the page a need. For that it is working find the thing is if I cancel that box of the printer that appear it will print anyway

I am not a pro in macro or visual basic so I hope that someone quant gives me hints to my problem

thank you
 
ActiveSheet.PageSetup.PrintArea = "$a$1:$h$60"
bResponse = Application.Dialogs(xlDialogPrinterSetup).Show
If bResponse = "False" Then Exit Sub
ActiveSheet.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "$a$1:$AA$60"


John
 
If Not Application.Dialogs(xlDialogPrinterSetup).Show Then Exit Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thank you

but Docjohn52 it did not work it still doen the same thing


for PHV


Private Sub CommandButton1_Click()

ActiveSheet.PageSetup.PrintArea = "$a$4:$h$63"
If Not Application.Dialogs(xlDialogPrinterSetup).Show Then Exit Sub
ActiveSheet.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "$a$4:$AA$60"

End Sub


this will work but now the thing is
a nned to go to ActiveSheet.PageSetup.PrintArea = "$a$4:$AA$60"
befor end sub so i will check on in the book that i have
tho see if there something a can do thank you for you time

Dockjohn52 and PHV
 
ok not it does work

the new macro is


Private Sub CommandButton1_Click()

ActiveSheet.PageSetup.PrintArea = "$a$4:$h$63"

If Not Application.Dialogs(xlDialogPrinterSetup).Show Then GoTo Fin:

ActiveSheet.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = "$a$4:$AA$63"

Fin:
ActiveSheet.PageSetup.PrintArea = "$a$4:$AA$63"

End Sub

thank you again for your time all of you

it was very fast solve me a big problem of wasting paper

 
Why not simply this ?
Private Sub CommandButton1_Click()
ActiveSheet.PageSetup.PrintArea = "$a$4:$h$63"
If Application.Dialogs(xlDialogPrinterSetup).Show Then
ActiveSheet.PrintOut Copies:=1, Collate:=True
End If
ActiveSheet.PageSetup.PrintArea = "$a$4:$AA$63"
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top