Excel Add MultiLine Textbox RRS feed

  • General discussion

  •    I have the following code
           tbox = Me.Controls.AddTextBox(64.5, 765, 567, 50, "Textbox1")
            tbox.Multiline = True
            tbox.Height = 150
            tbox.Text = TextBox
            AddHandler tbox.KeyPress, AddressOf TextBox1_KeyPress

    this runs without error but the textbox seems to ignore the height property
    • Changed type Tim Li Thursday, May 21, 2009 3:22 AM no response
    Wednesday, May 13, 2009 8:04 PM

All replies

  • I can't reproduce the problem - when I use your code the text box resizes - but I did change one line...

    tbox.Text = TextBox - You don't show how you define Textbox, but it's usually not a good idea to declare a variable with the same name as a Type (Dim tbox as TextBox). That can confuse things. I changed this to a string literal before I ran the code because Intellisense was showing it as a "Type".

    Do you have your code in a Try-Catch block? Sometimes, when Office applications encounter an error they break off silently if they're not in a Try-Catch.
    Cindy Meister, VSTO/Word MVP
    Friday, May 15, 2009 8:42 AM
  • We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the dropdown list at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


    We have published a VSTO FAQ recently, you can view them from the entry thread VSTO FAQ.
    If you have any feedbacks or suggestions on this FAQ, please feel free to write us emails to
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, May 21, 2009 3:22 AM