Confirmation Msgbox depending on Toggle button Caption

klarowe

Active Member
Joined
Mar 28, 2011
Messages
389
I am pretty much done with this latest project, but I'm going through and making a few last minute changes to make things even easier. I want to set up a messagebox that is activated before printing only if ToggleButton1.Caption = "Internal Copy" with the message "Are you sure you want to print an Internal Copy?"
Upon a "Yes" then continue printing; If "No", then cancel print

FYI, I currently have a before print application.run macro but I should be able to add this new one after that and have them both run... I think...

Any help is appreciated.
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hi,

Do you mean if the toggle button has been toggled?

Maybe this will help:

Code:
    If togglebutton1.Value = True Then
        confirmation = MsgBox("Are you sure you wish to print a copy?", vbYesNo)
        If confirmation = vbYes Then ...
 
Upvote 0
I can do it that way. Right now it is set up so that if the toggle value is true, it reads "internal copy" and if the value is false it reads "customer copy".
I can try to use what you posted above, but what should I use to continue / cancel the print depending on the vbyes/vbno??

Here is the code for ToggleButton1:
Code:
Private Sub ToggleButton1_Click()
    If ToggleButton1.Caption <> "Customer Copy" Then
        ToggleButton1.Caption = "Customer Copy"
        CallPressState
    Else
        ToggleButton1.Caption = "Internal Copy"
        CallPressState
    End If
End Sub
Sub CallPressState()
    If ToggleButton1.Caption = "Customer Copy" Then
        Application.Run "Hide"
    Else
        Application.Run "Unhide"
    End If
End Sub
 
Upvote 0
I got it figured out. I kept getting an error 424 because I wasn't calling out the sheet that housed the toggle button.

Final Code for future reference:
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Sheets("Index").ToggleButton1.Caption = "Internal Copy" Then
confirmation = MsgBox("Are you sure you wish to print an Internal Copy?", vbYesNo)
If confirmation = vbYes Then Exit Sub
If confirmation = vbNo Then Cancel = True
End If
End Sub
 
Last edited:
Upvote 0
Hi,

When the user clicks YES then it will print, if they don't then it will just jump to the next line in the routine. You could put an Else in there to make it easier to read if you wish, but it is not <!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";} </style> <![endif]-->necessarily required.

Code:
Sub CallPressState()
    If ToggleButton1.Caption = "Customer Copy" Then
        confirmation = MsgBox("Are you sure you wish to print?", vbYesNo)
        If confirmation = vbYes Then dostuff
        Application.Run "Hide"
    Else
 
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,919
Members
452,949
Latest member
beartooth91

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