mercredi 24 juin 2015

Import CheckBox Settings From Excel

I have an Excel worksheet that has 14 entries with checkboxes in it. I'd like to read the state of those checkboxes into a corresponding checkbox in Visual Basic. I'm struggling with this access, however. I believe I can only access the checkboxes in the Excel sheet by name, as I don't think they have an index like the Visual Basic checkbox does, so I think I have to check all 14 individually. So two questions:

1) Is it true I have to reference the Excel checkbox by name, as they're not associated with a specific index, correct (which also means 14 individual lines for access, rather than some sort of for loop)? 2) How do I actually read the value of the checkboxes into my Vsual Basic program? I have tried this: Dim oExcel As Excel.Application Dim oBook As Excel.Workbook Dim oSheet As Excel.Worksheet

    oExcel = New Excel.Application      'Create a new instance of Excel
    oExcel.Workbooks.Open("C:\QA Controller Test Files\" & SelectController.Text & ".xlsm")
    oSheet = oExcel.Worksheets(1)

    Dim checked As Boolean = oSheet.Shapes("Verify USB Revision Reporting").ControlFormat.Value
        If checked Then TestSelection.CheckedItems(1) = True

I get an error message that says "Interface 'Microsoft.Office.Interop.Excel.Shapes' cannot be indexed because it has no default property.




Aucun commentaire:

Enregistrer un commentaire