Print.Out Question from DialogPrinter

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

In calling xlDialogPrinterSetup from:

Code:
Sub PromptPrinter()
If Application.Dialogs(xlDialogPrinterSetup).Show = True Then

Sheets("Data").PrintOut From:=1, To:=12


End Sub

When the PrintOut dialog icon is then presented on the screen, if a user cancels this portion of the sub's action; How do I provide:

Code:
  'MsgBox "Canceled Print"

Thanks,
Pinaceous
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Application.Dialogs(xlDialogPrinterSetup).Show returns a Boolean value


Code:
    If Application.Dialogs(xlDialogPrinterSetup).Show Then
        Sheets("Data").PrintOut From:=1, To:=12
    Else
        MsgBox "Cancelled Print"
    End If
 
Last edited:
Upvote 0
Hey Yongle,

What I would like based on your post:

Application.Dialogs(xlDialogPrinterSetup).Show returns a Boolean value

Is there a way to block the applications Boolean value cancel button ?

Many thanks,
Paul
 
Upvote 0
Try (untested)

Code:
[COLOR=#ff0000]Repeat: [/COLOR]
   If Application.... Then

   Else
       [COLOR=#ff0000]  GoTo Repeat[/COLOR]
   End If
 
Upvote 0
Hey your last, the repeat is acting like a loop, right?

I can put a loop on it as well then, right?
 
Upvote 0
Could you please provide a code for the proposed loop?
 
Upvote 0
This is the loop forcing the user to select a printer

Code:
Sub PromptPrinter()
Repeat:
    If Application.Dialogs(xlDialogPrinterSetup).Show Then
        Sheets("Data").PrintOut From:=1, To:=12
    Else
        MsgBox "Cancelling is not permitted"
        GoTo Repeat
    End If
End Sub
Could you please provide a code for the proposed loop?
Please explain what you are trying to achieve
What is in your loop? :confused:
 
Upvote 0

Forum statistics

Threads
1,223,754
Messages
6,174,317
Members
452,555
Latest member
colc007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top