I've tried the things here on the internet but I still can't make it work.
My code is like this:
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim oRng As Excel.Range
If Center_for_Patient_PartnershipsCboxCheckBox.CheckState = CheckState.Checked Then
oSheet.OLEObjects("Check Box 1").Object.Value = 1
Else
oSheet.OLEObjects("Check Box 1").Object.Value = 0
End If`
If it's a Form Control check box:
oSheet.Shapes("Check box 1").ControlFormat.Value = 0 'Uncheck
oSheet.Shapes("Check box 1").ControlFormat.Value = 1 'Check
If it's an Active X check box:
oSheet.OLEObjects("CheckBox1").Object.Value = 0 'Uncheck
oSheet.OLEObjects("CheckBox1").Object.Value = 1 'Check
Notice that the name of the active x control can't have spaces but the form control check box can. This is why I provided both answers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.