Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Textbox - Shape : How to control from vba

  Asked By: Daisy    Date: Dec 20    Category: MS Office    Views: 2975
  

I wonder if someone can give me some syntax to be able to control a draw
text box on the sheet - not on a form

The text box object as in from the drawing toolbar as I need a couple of
textbox to overlap cells on the worksheet

I did run a bit of code which i found off msdn about listing through all the
text boxes

Dim tbox As TextBox
For Each tbox In ActiveSheet.TextBoxes
tbox.Text = UCase(tbox.Text)
Next tbox

Then i used the watch window and monitor tbox as it stepped through all of
them
I found that the values i need to address are as follows

Name = in my test case this was "sausage" as i had named the textbox
Caption = "this is a test"
Text = "this is a test"

But is there a way to directly write and read to the textbox named sausage
.. sorry still a bit of a novice at this !

I also understand the alternative is way is draw text box and then select it
; press f2 ; point it a cell ; then use my code to write to that cell

Hope someone can advise or point me in the right direction

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Fabian Jones     Answered On: Dec 20

debug.print Activesheet.textboxes("Text box  1").top
Activesheet.textboxes("Text Box 1").top=150
Activesheet.textboxes("sausage").top=150
Activesheet.textboxes("sausage").text="sausages'n'mash"
debug.print Activesheet.textboxes("sausages").text

To get an idea of the properties/methods available, while stepping
through (with F8) the vba  you quoted below, stop while in the middle
of the loop and in the immediate pane type:
?tbox.
and when you type the full-stop (period for US residents) you should
get a dropdown list of what's available. Also, in the Locals pane,
you'll be able to look at more info on tbox by expanding its tree.

 
Answer #2    Answered By: Clariss Ferrrari     Answered On: Dec 20

its a bit  late now.. i will give  it a go..

 
Didn't find what you were looking for? Find more on Textbox - Shape : How to control from vba Or get search suggestion and latest updates.




Tagged: