ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox question (https://www.excelbanter.com/excel-programming/332575-textbox-question.html)

Vince

Textbox question
 
I created a graph and inserted it as a new sheet that is named "Graph". On
this chart, then placed a textbox. I would like to know if there is a way in
VB to update this textbox with the results of calculations that are done
within a VB routine. In VB6 it was simple to do Textbox1.text = "Some Text",
but I don't seem to be able to do the same in VB for Excel. I have tried
Sheets("Graph").textbox1.text, Chart1.textbox1.text, etc but with no luck.
Can someone provide help with this.

Thank you
Vince


Jim Thomlinson[_4_]

Textbox question
 
What you have should work. A couple of possible problems though. Ensure that
you have a text box off the Control Toolbox toolbar not an edit box off the
forms toolbar. When your sheet is in design mode in the formula bar you
should see the following:

=EMBED("Forms.TextBox.1","")

In the VBE if you type in (Assuming the graph sheet is sheet 2)

Sheet2.

the intelisence dropdown should include "TextBox1" in the list. (you will
not get an intellisence dropdown if you use sheets("Graph"). as the sheet tab
name can change at run time)

Confirm these things and if there is still a problem let me know...
--
HTH...

Jim Thomlinson


"Vince" wrote:

I created a graph and inserted it as a new sheet that is named "Graph". On
this chart, then placed a textbox. I would like to know if there is a way in
VB to update this textbox with the results of calculations that are done
within a VB routine. In VB6 it was simple to do Textbox1.text = "Some Text",
but I don't seem to be able to do the same in VB for Excel. I have tried
Sheets("Graph").textbox1.text, Chart1.textbox1.text, etc but with no luck.
Can someone provide help with this.

Thank you
Vince


Vince

Textbox question
 
Jim,
Thanks for the feedback.
I can not add a textbox from the Control Toolbox. When I select the chart,
the Control Toolbox toolbar all goes gray. The only texbox I can get is off
of the drawing toolbar. Do I have a setting wrong in excel or something. I
added a textbox to a worksheet, selected it and see your note about the
"=Embed", but the toolbar is grayed out when I select the chart.

Vince


"Jim Thomlinson" wrote:

What you have should work. A couple of possible problems though. Ensure that
you have a text box off the Control Toolbox toolbar not an edit box off the
forms toolbar. When your sheet is in design mode in the formula bar you
should see the following:

=EMBED("Forms.TextBox.1","")

In the VBE if you type in (Assuming the graph sheet is sheet 2)

Sheet2.

the intelisence dropdown should include "TextBox1" in the list. (you will
not get an intellisence dropdown if you use sheets("Graph"). as the sheet tab
name can change at run time)

Confirm these things and if there is still a problem let me know...
--
HTH...

Jim Thomlinson


"Vince" wrote:

I created a graph and inserted it as a new sheet that is named "Graph". On
this chart, then placed a textbox. I would like to know if there is a way in
VB to update this textbox with the results of calculations that are done
within a VB routine. In VB6 it was simple to do Textbox1.text = "Some Text",
but I don't seem to be able to do the same in VB for Excel. I have tried
Sheets("Graph").textbox1.text, Chart1.textbox1.text, etc but with no luck.
Can someone provide help with this.

Thank you
Vince


Jim Thomlinson[_4_]

Textbox question
 
Off the drwaing toolbar you get objects unlike the vb objects you are used
to. They are actually shapes. Try this code to see if it is what you want...

Sub test()
Dim txtBox As Shape

Set txtBox = Chart1.Shapes("Text Box 1")

txtBox.DrawingObject.Caption = "Weeee"

End Sub

--
HTH...

Jim Thomlinson


"Vince" wrote:

Jim,
Thanks for the feedback.
I can not add a textbox from the Control Toolbox. When I select the chart,
the Control Toolbox toolbar all goes gray. The only texbox I can get is off
of the drawing toolbar. Do I have a setting wrong in excel or something. I
added a textbox to a worksheet, selected it and see your note about the
"=Embed", but the toolbar is grayed out when I select the chart.

Vince


"Jim Thomlinson" wrote:

What you have should work. A couple of possible problems though. Ensure that
you have a text box off the Control Toolbox toolbar not an edit box off the
forms toolbar. When your sheet is in design mode in the formula bar you
should see the following:

=EMBED("Forms.TextBox.1","")

In the VBE if you type in (Assuming the graph sheet is sheet 2)

Sheet2.

the intelisence dropdown should include "TextBox1" in the list. (you will
not get an intellisence dropdown if you use sheets("Graph"). as the sheet tab
name can change at run time)

Confirm these things and if there is still a problem let me know...
--
HTH...

Jim Thomlinson


"Vince" wrote:

I created a graph and inserted it as a new sheet that is named "Graph". On
this chart, then placed a textbox. I would like to know if there is a way in
VB to update this textbox with the results of calculations that are done
within a VB routine. In VB6 it was simple to do Textbox1.text = "Some Text",
but I don't seem to be able to do the same in VB for Excel. I have tried
Sheets("Graph").textbox1.text, Chart1.textbox1.text, etc but with no luck.
Can someone provide help with this.

Thank you
Vince



All times are GMT +1. The time now is 09:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com