PDA

View Full Version : Visio Help for Input Text



vbstarter
05-30-2006, 01:20 PM
Assume that I drag a rectangle and drop it to the window. Once I drop that rectangle, I want to change the text. I try to change text automatically. For instance, I create a combobox in a form to select the text, however I don't know how to transfer the text to the shape.

Here is the code for the form


Sub test()
UserForm1.ComboBox1.AddItem ("Computer")
UserForm1.ComboBox1.AddItem ("Monitor")
UserForm1.ComboBox1.AddItem ("Keyboard")
UserForm1.ComboBox1.AddItem ("Other Devices")
UserForm1.ComboBox1.ListIndex = 0

UserForm1.Show (1)

End Sub


The other part of the code


Private Sub CommandButton1_Click()
Dim Response
Dim vsRectangle As Visio.Shape

vsRectangle.Text = "Change text"
Response = MsgBox("The text was change", vbOKCancel, "My Title")
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub



I put this thread to the word section, since I did not find one for visio

fumei
05-31-2006, 05:59 AM
Not sure I understand the question.

If you have the combobox items filled when the userform is initialized (Userform1_Initialize() ), then the items are there. In which case:Sub CommandButton1_Click()
Dim Response
Dim vsRectangle As Visio.Shape

vsRectangle.Text = Comboxbox1.Text
Response = MsgBox("The text was change", vbOKCancel, "My Title")
End Sub will use the current text in the combobox. Is this what you are asking?

vbstarter
05-31-2006, 06:41 AM
What I want to do, take the text from the combobox and pass it to the rectangle. The way to look at it, I want to change the text of the rectangle shape programmatically. The text from the combobox will be the text of the shape. It is like double clicking on the shape and type something.


Not sure I understand the question.

If you have the combobox items filled when the userform is initialized (Userform1_Initialize() ), then the items are there. In which case:Sub CommandButton1_Click()
Dim Response
Dim vsRectangle As Visio.Shape

vsRectangle.Text = Comboxbox1.Text
Response = MsgBox("The text was change", vbOKCancel, "My Title")
End Sub will use the current text in the combobox. Is this what you are asking?

vbstarter
05-31-2006, 09:58 AM
I tried your code, I received error "424" object required

I also received the following error from this line

vsRectangle.Text = Comboxbox1.Text "object variable or with block variable not set"

fumei
05-31-2006, 09:29 PM
Well then, either:

1. there is no vsRectangle; OR
2. there is no Combobox1

So...test which is which. However, I would like to point out that names are important. It is likely that you not have a Comboxbox1 - it is likely Combobox1. Without the extra "x".

Sorry, I obviously typed the extra "x" in my post. I suggest you check your code.

vbstarter
06-01-2006, 07:54 AM
This is the only code I have for the macro


Private Sub CommandButton1_Click()
Dim Response
Dim vsRectangle As Visio.Shape

vsRectangle.Text = ComboBox1.Text
Response = MsgBox("The text was change", vbOKCancel, "My Title")
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub



and


Sub test()
UserForm1.ComboBox1.AddItem ("Computer")
UserForm1.ComboBox1.AddItem ("Monitor")
UserForm1.ComboBox1.AddItem ("Keyboard")
UserForm1.ComboBox1.AddItem ("Other Devices")
UserForm1.ComboBox1.ListIndex = 0

UserForm1.Show (1)

End Sub


I did remove the "x" from the combobox, but I still receive the same error, object variable or with block variable is not set. The problem may be, even I have the rectangle on the drawing, but visio does not know if it is selected or named.