Thursday, December 5, 2019

 

1. Create and set/get value to control




Access ActiveX Controls by:
Worksheet("sheetname").ComponentName

Ex:
Sub main()
    Debug.Print ActiveSheet.TextBoxName.Value
    'or
    Debug.Print ActiveSheet.OLEObjects("TextBoxName").Object.Value
End Sub

For how to set/get component value, reference to UserForm


2. Get type of  ActiveX control

Sub getTypeControl()
    Dim ws As Worksheet
    Dim oleob As OLEObject
    Set ws = ActiveSheet
    
    For Each oleob In ws.OLEObjects
        If TypeName(oleob.Object) = "TextBox" Then 'if type: TextBox
        
            oleob.Object.Value = "hihi haha"

        End If
    Next
End Sub




Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Lập trình hệ thống nhúng Linux . Powered by Luong Duy Ninh -