Create activex textbox automatically and fill it

YasserKhalil
PlatinumLounger
Posts: 4912
Joined: 31 Aug 2016, 09:02

Create activex textbox automatically and fill it

Post by YasserKhalil »

Hello everyone
I am trying to create activex textbox and that part is OK. What I am stuck at is how to fill the created textbox
This is my try that failed at the last line

Code: Select all

Sub Test()
    Dim oTextBox As OLEObject
    Set oTextBox = ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1")
    With oTextBox
        .Name = "TextBox1"
        .Left = 400
        .Width = 200
        .Height = 300
    End With
    ActiveSheet.TextBox1.Value = "Hello"
End Sub

YasserKhalil
PlatinumLounger
Posts: 4912
Joined: 31 Aug 2016, 09:02

Re: Create activex textbox automatically and fill it

Post by YasserKhalil »

I have searched till I found this that solved the problem

Code: Select all

.Object.Text = "Hello"

User avatar
HansV
Administrator
Posts: 78415
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Create activex textbox automatically and fill it

Post by HansV »

Yes, that is the solution. Good that you found it.
Best wishes,
Hans