Reach ActiveX or Form objects (textbox) from codebehind in an Excel document

后端 未结 5 1532
别跟我提以往
别跟我提以往 2021-01-11 23:43

There are several textboxes in an excel file as ActiveX objects and I want to reach them from codebehind.

I am using ClosedXML for other fields, but I am open for ot

5条回答
  •  爱一瞬间的悲伤
    2021-01-12 00:18

    You can iterate all the OLE objects as below and identify the textbox you need by textbox name or textbox Text. Instead of Me, you can use worksheet refrence from outside the workbook or any code.

    Private Sub GetActiveXControls()
    
      For Each Item In Me.OLEObjects
        'Debug.Print Item.Name
        If TypeName(Item.Object) = "TextBox" Then
          Debug.Print "text = " & Item.Object.text
        End If
      Next
    
    End Sub
    

提交回复
热议问题