I need some help on this one. I have a userform that runs multiple macros based on selected checkboxes, each checkbox controlling their own macro. What I am looking for is the ability to use these same checkboxes to select certain sheets to print.
pseudocode,
commandbutton print (start code)
Print = 1 (enable variable to only run enabled code)
Check values of checkboxes
run only the print codes if true
Print = 0 (reset variable to normal mode)
end
any help with this will be appreciated.
'Userform1
Private Sub CommandButton1_Click()
Dim I As Long
ClearCells
If UserForm1.CheckBox1.Value = True Then
LegendPlatesSht1
Application.Run "'Label_Generator.xlsm'!Sheet7.CommandButton5_Click"
I = I + 1
End If
If UserForm1.CheckBox2.Value = True Then
LegendPlatesSht_1
Application.Run "'Label_Generator.xlsm'!Sheet7.CommandButton6_Click"
I = I + 1
End If
If UserForm1.CheckBox3.Value = True Then
LegendPlateSht2
Application.Run "'Label_Generator.xlsm'!Sheet7.CommandButton7_Click"
I = I + 1
End If
If UserForm1.CheckBox4.Value = True Then
StandardLegendPlates1
transpose
Application.Run "'Label_Generator.xlsm'!Sheet14.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox5.Value = True Then
MedDeviceTagsSingleLine
Application.Run "'Label_Generator.xlsm'!Sheet8.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox6.Value = True Then
CallMediumDeviceTagsDualLine1
Application.Run "'Label_Generator.xlsm'!Sheet12.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox7.Value = True Then
SmallDeviceTags
Application.Run "'Label_Generator.xlsm'!Sheet9.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox8.Value = True Then
MedMtrTag300
Application.Run "'Label_Generator.xlsm'!Sheet11.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox9.Value = True Then
MedMtrTag325
Application.Run "'Label_Generator.xlsm'!Sheet11.CommandButton2_Click"
I = I + 1
End If
If UserForm1.CheckBox10.Value = True Then
MedMtrTag350
Application.Run "'Label_Generator.xlsm'!Sheet11.CommandButton3_Click"
I = I + 1
End If
If UserForm1.CheckBox11.Value = True Then
MedMtrTag375
Application.Run "'Label_Generator.xlsm'!Sheet11.CommandButton4_Click"
I = I + 1
End If
If UserForm1.CheckBox12.Value = True Then
LargeULPanelTag
Application.Run "'Label_Generator.xlsm'!Sheet10.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox13.Value = True Then
LargePanelTag
Application.Run "'Label_Generator.xlsm'!Sheet13.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox14.Value = True Then
SmallPanelTag
Application.Run "'Label_Generator.xlsm'!Sheet16.CommandButton1_Click"
I = I + 1
End If
If UserForm1.CheckBox15.Value = True Then
SWSerialMDLtag
Application.Run "'Label_Generator.xlsm'!Sheet17.CommandButton1_Click"
I = I + 1
End If
clearcheckboxes
If I = 0 Then
MsgBox "No checkboxes checked."
Else
MsgBox I & " subs completed."
End If
End Sub
Private Sub CommandButton6_Click()
Print_Current_Workbook
End Sub
'module 2
Sub Print_Current_Workbook()
Dim myprinter As String
Dim printer_name As sttring
printer_name = "HP LaserJet P1006"
myprinter = Application.ActivePrinter
Change_Form.PrintOut Preview:=False, ActivePrinter:=printer_name, PrintToFile:=False, PrToFileName:=PSFileName
Application.ActivePrinter = myprinter
'Prints the current active workbook in Excel
ActiveWorkbook.PrintOut
End Sub
Bookmarks