Print.Out Question from DialogPrinter

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
589
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
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,314
Office Version
365
Platform
Windows
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:

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
589
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
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,314
Office Version
365
Platform
Windows
Try (untested)

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

   Else
       [COLOR=#ff0000]  GoTo Repeat[/COLOR]
   End If
 

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
589
Hey your last, the repeat is acting like a loop, right?

I can put a loop on it as well then, right?
 

Yongle

Well-known Member
Joined
Mar 11, 2015
Messages
5,314
Office Version
365
Platform
Windows
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:
 

Watch MrExcel Video

Forum statistics

Threads
1,090,551
Messages
5,415,227
Members
403,573
Latest member
ballardgirl

This Week's Hot Topics

Top