Print and Print Preview

In a module I have the following code:
Sub PrintSheet()
    Dim UserResponse 
    UserResponse = MsgBox(Prompt:="Print Worksheet", Buttons:=vbYesNoCancel, Title:="Print Worksheet")
    Select Case UserResponse
        Case vbCancel
            Exit Sub
        Case vbYes
           Selection.PrintOut
        Case Else
           Selection.PrintOut Preview:=True
    End Select

End sub 

Open in new window


In a command button I call the module code:
Sub cmdPrintProduction_Click()
    PrintSheet
End Sub

Open in new window


My objective is to have the user select a Print Option through  a command button (there will be hundereds of worksheets (each with a Print command button). They can select Print Preview and Print or simply Print. When I select Print Preview I get a only the first row; When I select Print I get a blank sheet of paper. Therefore, I must have something wrong in my module.
Frank FreeseAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

[ fanpages ]IT Services ConsultantCommented:
Hi,

I would suggest that what is being printed is a single cell, & what is being previewed is the row where the selected single cell resides.

Try changing:

Selection.PrintOut
to
Cells.PrintOut
or
ActiveSheet.PrintOut Preview:=True


Similarly,

Selection.PrintOut Preview:=True
to
Cells.PrintOut Preview:=True
or
ActiveSheet.PrintOut Preview:=True

BFN,

fp.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Frank FreeseAuthor Commented:
ActiveSheet.PrintOut Preview:=True

ActiveSheet.PrintOut Preview:=True

These worked

Thanks
0
Frank FreeseAuthor Commented:
thank you
I appreciate it
0
[ fanpages ]IT Services ConsultantCommented:
You're very welcome.

Good luck with the rest of your project.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.