Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically create a text box in a Excel Sheet 1

Status
Not open for further replies.

barnard89

MIS
Mar 6, 2005
74
US
Hi

I am using Excel 2000
I need to dynamically create a text box
on my excel sheet whenever I press a button
which is on my excel sheet

Could some one suggest me the method and code as
to how I can do it

thanks

 
Have you tried to play with the macrorecorder ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Easist way is to use macro recorder and look at the code.

That is, record a macro of you manually adding a text box.
 
Hi


Thanks for your reply

this works.
I can create the text box dynamically

But I am not able ot assign any properties of the text box dynamically
I would also like to assign the forecolor ,
width and font style of the text box when it is being created

Can I do it ?

thanks
 


AFTER it's created, TURN ON THE MACRO RECORDER and record changing the properties -- Format/...

Skip,

[glasses] [red]Be advised:[/red]When Viscounts were guillotined just as they were disclosing where their jewels were hidden, it shows to go that you should...
Never hatchet your Counts before they chicken! [tongue]
 
Again, with the recorder..

Code:
    ActiveSheet.Shapes.AddTextbox(msoTextOrientationHorizontal, 106.5, 23.25, _
        121.5, 39.75).Select
    Selection.Characters.Text = ""
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Regular"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "Bold"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
    End With
    Selection.ShapeRange.Fill.Visible = msoTrue
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = 53
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 0.75
    Selection.ShapeRange.Line.DashStyle = msoLineSolid
    Selection.ShapeRange.Line.Style = msoLineSingle
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.SchemeColor = 64
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    Range("D8").Select

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top