I am trying to create a macro that will print the selected sheets out of a workbook. The first worksheet has a set of Checkboxes that all follow the naming convention "CheckBoxX" where X is the number of that checkbox. What I'd like the code to do, is run through each of these checkboxes, see if it's checked, then select that corresponding worksheet if it is checked. However, I'm getting an error "Object doesn't support this property or method".
Here's my code: Code:
Option Explicit
Sub Button14_Click()
Dim count As Integer
Dim checkNumber As String
For count = 1 To ThisWorkbook.Worksheets.count
checkNumber = "CheckBox" & count
If Sheets("Print").Shapes(checkNumber).OLEFormat.Object.Value = True Then
Worksheets(count + 1).Select (False)
End If
Next count
ActiveWindow.SelectedSheets.PrintOut
End Sub
The debug always flags the line with the if statement.
I have also tried this as my if statement: Code:
If Sheets("Print").Shapes(checkNumber).ControlFormat.Value = 1 Then
Aucun commentaire:
Enregistrer un commentaire