+ Reply to Thread
Results 1 to 5 of 5

Set Properties of TextBox in VBA

  1. #1
    Don Rouse
    Guest

    Set Properties of TextBox in VBA

    I am adding a textbox and trying to set its properties using VBA. I get the
    box but cannot figureout haw to set the properties.

    Here is part of my code:

    ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
    DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30, Height:=18). _
    Select

    With Selection
    .Placement = xlMoveAndSize
    .PrintObject = False
    End With

    ' I want to set the properties of textbox1 here,
    ' but do not know how to do it. Need to set LinkedCell and Value.

    Your assistance is appreciated. Thank you.
    --
    Don

  2. #2
    Nigel
    Guest

    Re: Set Properties of TextBox in VBA

    ActiveSheet.OLEObjects("TextBox1").LinkedCell = "A1"
    ActiveSheet.OLEObjects("Textbox1").Object.Value = "Text"


    --
    Cheers
    Nigel



    "Don Rouse" <[email protected]> wrote in message
    news:[email protected]...
    > I am adding a textbox and trying to set its properties using VBA. I get

    the
    > box but cannot figureout haw to set the properties.
    >
    > Here is part of my code:
    >
    > ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
    > DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30, Height:=18).

    _
    > Select
    >
    > With Selection
    > .Placement = xlMoveAndSize
    > .PrintObject = False
    > End With
    >
    > ' I want to set the properties of textbox1 here,
    > ' but do not know how to do it. Need to set LinkedCell and Value.
    >
    > Your assistance is appreciated. Thank you.
    > --
    > Don




  3. #3
    Bob Phillips
    Guest

    Re: Set Properties of TextBox in VBA

    Better not to assume the name allocated

    With ActiveSheet.OLEObjects
    Set tb = .Add(ClassType:="Forms.TextBox.1", Link:=False, _
    DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30,
    Height:=18)
    tb.Name = "Bob"
    tb.LinkedCell = "A1"
    tb.Object.Value = "Text"
    End With

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Nigel" <[email protected]> wrote in message
    news:[email protected]...
    > ActiveSheet.OLEObjects("TextBox1").LinkedCell = "A1"
    > ActiveSheet.OLEObjects("Textbox1").Object.Value = "Text"
    >
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    > "Don Rouse" <[email protected]> wrote in message
    > news:[email protected]...
    > > I am adding a textbox and trying to set its properties using VBA. I get

    > the
    > > box but cannot figureout haw to set the properties.
    > >
    > > Here is part of my code:
    > >
    > > ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
    > > DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30,

    Height:=18).
    > _
    > > Select
    > >
    > > With Selection
    > > .Placement = xlMoveAndSize
    > > .PrintObject = False
    > > End With
    > >
    > > ' I want to set the properties of textbox1 here,
    > > ' but do not know how to do it. Need to set LinkedCell and Value.
    > >
    > > Your assistance is appreciated. Thank you.
    > > --
    > > Don

    >
    >




  4. #4
    Don Rouse
    Guest

    Re: Set Properties of TextBox in VBA

    Bob,

    Thank you. It works fine.
    --
    Don


    "Bob Phillips" wrote:

    > Better not to assume the name allocated
    >
    > With ActiveSheet.OLEObjects
    > Set tb = .Add(ClassType:="Forms.TextBox.1", Link:=False, _
    > DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30,
    > Height:=18)
    > tb.Name = "Bob"
    > tb.LinkedCell = "A1"
    > tb.Object.Value = "Text"
    > End With
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Nigel" <[email protected]> wrote in message
    > news:[email protected]...
    > > ActiveSheet.OLEObjects("TextBox1").LinkedCell = "A1"
    > > ActiveSheet.OLEObjects("Textbox1").Object.Value = "Text"
    > >
    > >
    > > --
    > > Cheers
    > > Nigel
    > >
    > >
    > >
    > > "Don Rouse" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I am adding a textbox and trying to set its properties using VBA. I get

    > > the
    > > > box but cannot figureout haw to set the properties.
    > > >
    > > > Here is part of my code:
    > > >
    > > > ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
    > > > DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30,

    > Height:=18).
    > > _
    > > > Select
    > > >
    > > > With Selection
    > > > .Placement = xlMoveAndSize
    > > > .PrintObject = False
    > > > End With
    > > >
    > > > ' I want to set the properties of textbox1 here,
    > > > ' but do not know how to do it. Need to set LinkedCell and Value.
    > > >
    > > > Your assistance is appreciated. Thank you.
    > > > --
    > > > Don

    > >
    > >

    >
    >
    >


  5. #5
    Don Rouse
    Guest

    Re: Set Properties of TextBox in VBA

    Nigel,

    Thank you. Your code works fine.
    --
    Don


    "Nigel" wrote:

    > ActiveSheet.OLEObjects("TextBox1").LinkedCell = "A1"
    > ActiveSheet.OLEObjects("Textbox1").Object.Value = "Text"
    >
    >
    > --
    > Cheers
    > Nigel
    >
    >
    >
    > "Don Rouse" <[email protected]> wrote in message
    > news:[email protected]...
    > > I am adding a textbox and trying to set its properties using VBA. I get

    > the
    > > box but cannot figureout haw to set the properties.
    > >
    > > Here is part of my code:
    > >
    > > ActiveSheet.OLEObjects.Add(ClassType:="Forms.TextBox.1", Link:=False, _
    > > DisplayAsIcon:=False, Left:=500, Top:=690, Width:=30, Height:=18).

    > _
    > > Select
    > >
    > > With Selection
    > > .Placement = xlMoveAndSize
    > > .PrintObject = False
    > > End With
    > >
    > > ' I want to set the properties of textbox1 here,
    > > ' but do not know how to do it. Need to set LinkedCell and Value.
    > >
    > > Your assistance is appreciated. Thank you.
    > > --
    > > Don

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1