Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 10
Default Syntax for selecting a textbox within a chart?

I am writing a macro that will insert text & a cell value into a similarly
named text box within multiple charts, but being a noob with VBA, I'm not
sure of the syntax to use to select the text box in question. I was starting
with a simple bit of code that did the same thing for the ChartTitle:

ActiveChart.ChartTitle.Select
Selection.Characters.Text = "text here" & <value

I tried to use:

ActiveChart.TextBoxes("Text Box 1").Select
Selection.Characters.Text = "text here" & <value

.... as well as trying it a few other ways, but keep getting the error
"Method 'TextBoxes' of object '_Chart failed"

What am I missing?

Thank you!
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default Syntax for selecting a textbox within a chart?

Hi,

Something like this for a textbox with the name 'Text Box 1'

ActiveChart.Shapes("Text Box 1").TextFrame.Characters.Text = "text here" &
123

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"tenlbham" wrote in message
...
I am writing a macro that will insert text & a cell value into a similarly
named text box within multiple charts, but being a noob with VBA, I'm not
sure of the syntax to use to select the text box in question. I was
starting
with a simple bit of code that did the same thing for the ChartTitle:

ActiveChart.ChartTitle.Select
Selection.Characters.Text = "text here" & <value

I tried to use:

ActiveChart.TextBoxes("Text Box 1").Select
Selection.Characters.Text = "text here" & <value

... as well as trying it a few other ways, but keep getting the error
"Method 'TextBoxes' of object '_Chart failed"

What am I missing?

Thank you!


  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Syntax for selecting a textbox within a chart?

You might find it advantageous to construct the text in a cell, then link
the textbox to that cell. This makes it easier to update in the futu

ActiveChart.Textboxes(1).Formula = "=Sheet1!$A$1"

I can't seem to navigate my way to this formula using the Shapes object. You
can apply a cell's value to an axis title in a different way:

ActiveChart.ChartTitle.Text = "=Sheet1!R1C1"

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Andy Pope" wrote in message
...
Hi,

Something like this for a textbox with the name 'Text Box 1'

ActiveChart.Shapes("Text Box 1").TextFrame.Characters.Text = "text here" &
123

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"tenlbham" wrote in message
...
I am writing a macro that will insert text & a cell value into a similarly
named text box within multiple charts, but being a noob with VBA, I'm not
sure of the syntax to use to select the text box in question. I was
starting
with a simple bit of code that did the same thing for the ChartTitle:

ActiveChart.ChartTitle.Select
Selection.Characters.Text = "text here" & <value

I tried to use:

ActiveChart.TextBoxes("Text Box 1").Select
Selection.Characters.Text = "text here" & <value

... as well as trying it a few other ways, but keep getting the error
"Method 'TextBoxes' of object '_Chart failed"

What am I missing?

Thank you!




  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 10
Default Syntax for selecting a textbox within a chart?

That's it! Thanks Andy.

Jon P, I do use cell-value linking for other areas of my charts, but it
didn't work in this case. I wanted a simple way to put both text and a cell
value into the same text box. Thanks, though.

"Andy Pope" wrote:

Hi,

Something like this for a textbox with the name 'Text Box 1'

ActiveChart.Shapes("Text Box 1").TextFrame.Characters.Text = "text here" &
123

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"tenlbham" wrote in message
...
I am writing a macro that will insert text & a cell value into a similarly
named text box within multiple charts, but being a noob with VBA, I'm not
sure of the syntax to use to select the text box in question. I was
starting
with a simple bit of code that did the same thing for the ChartTitle:

ActiveChart.ChartTitle.Select
Selection.Characters.Text = "text here" & <value

I tried to use:

ActiveChart.TextBoxes("Text Box 1").Select
Selection.Characters.Text = "text here" & <value

... as well as trying it a few other ways, but keep getting the error
"Method 'TextBoxes' of object '_Chart failed"

What am I missing?

Thank you!


  #5   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Syntax for selecting a textbox within a chart?

The simple way is to combine the text and value in a cell, then link the
cell to the textbox. Any formula in a textbox or other chart text element
can only be a link to a cell, and cannot include any operations.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"tenlbham" wrote in message
...
That's it! Thanks Andy.

Jon P, I do use cell-value linking for other areas of my charts, but it
didn't work in this case. I wanted a simple way to put both text and a
cell
value into the same text box. Thanks, though.

"Andy Pope" wrote:

Hi,

Something like this for a textbox with the name 'Text Box 1'

ActiveChart.Shapes("Text Box 1").TextFrame.Characters.Text = "text here"
&
123

Cheers
Andy

--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"tenlbham" wrote in message
...
I am writing a macro that will insert text & a cell value into a
similarly
named text box within multiple charts, but being a noob with VBA, I'm
not
sure of the syntax to use to select the text box in question. I was
starting
with a simple bit of code that did the same thing for the ChartTitle:

ActiveChart.ChartTitle.Select
Selection.Characters.Text = "text here" & <value

I tried to use:

ActiveChart.TextBoxes("Text Box 1").Select
Selection.Characters.Text = "text here" & <value

... as well as trying it a few other ways, but keep getting the error
"Method 'TextBoxes' of object '_Chart failed"

What am I missing?

Thank you!






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formating textbox on a chart Roger B. Charts and Charting in Excel 10 November 10th 06 02:17 AM
writing data to a textbox in a chart CLamar Excel Discussion (Misc queries) 0 July 21st 06 02:57 PM
Why does my textbox disappear when I put it on a chart? krbear Charts and Charting in Excel 2 April 6th 06 11:56 PM
how do i draw a textbox on chart and copy onto word? miko Charts and Charting in Excel 2 March 12th 05 04:36 AM
manipulating textbox in chart Peter Hafner Charts and Charting in Excel 0 January 31st 05 10:55 AM


All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"