ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Characters Method - Need Help (https://www.excelbanter.com/excel-programming/412058-textbox-characters-method-need-help.html)

MarkCR

TextBox Characters Method - Need Help
 
Greetings:

I have the following line in an Excel VBA Macro:

ActiveChart.Shapes.AddTextbox(msoTextOrientationHo rizontal, 500, 80, 120,
60).Select
Selection.AutoScaleFont = False
Selection.Characters(Start:=1, Length:=23).Font.Name = "Arial"

It runs perfectly well under Excell 2003, but under Excel 2007, I get the
following, very unhelpful, error message:

"Runtime error: 1004
Unable to get the Characters property of the TextBox class."

Sooo, what does unable to "get" the property mean. It doesn't exist? Has it
been removed? Am I not using it properly? Most important: What has changed in
Excel 2007 that this no longer works?

Thank you,
Mark


Dave Peterson

TextBox Characters Method - Need Help
 
From what I've read in the newsgroup, xl2007 has trouble when you select shapes.

Maybe you could do it without the selection:

Dim myTB As Shape
Set myTB = ActiveChart.Shapes.AddTextbox _
(msoTextOrientationHorizontal, 500, 80, 120, 60)

myTB.OLEFormat.Object.AutoScaleFont = False
myTB.OLEFormat.Object.Characters(Start:=1, Length:=23).Font.Name = "Arial"

MarkCR wrote:

Greetings:

I have the following line in an Excel VBA Macro:

ActiveChart.Shapes.AddTextbox(msoTextOrientationHo rizontal, 500, 80, 120,
60).Select
Selection.AutoScaleFont = False
Selection.Characters(Start:=1, Length:=23).Font.Name = "Arial"

It runs perfectly well under Excell 2003, but under Excel 2007, I get the
following, very unhelpful, error message:

"Runtime error: 1004
Unable to get the Characters property of the TextBox class."

Sooo, what does unable to "get" the property mean. It doesn't exist? Has it
been removed? Am I not using it properly? Most important: What has changed in
Excel 2007 that this no longer works?

Thank you,
Mark


--

Dave Peterson

MarkCR

TextBox Characters Method - Need Help
 
Hi Dave:

Thanks for your response. It seemed like the right answer, but I am getting
the same error on the line:

myTB.OLEFormat.Object.Characters(Start:=1, Length:=23).Font.Name = "Arial"

Very strange...
Mark

"Dave Peterson" wrote:

From what I've read in the newsgroup, xl2007 has trouble when you select shapes.

Maybe you could do it without the selection:

Dim myTB As Shape
Set myTB = ActiveChart.Shapes.AddTextbox _
(msoTextOrientationHorizontal, 500, 80, 120, 60)

myTB.OLEFormat.Object.AutoScaleFont = False
myTB.OLEFormat.Object.Characters(Start:=1, Length:=23).Font.Name = "Arial"



Dave Peterson

TextBox Characters Method - Need Help
 
Sorry.

Try:

myTB.OLEFormat.Object.AutoScaleFont = False
myTB.TextFrame.Characters.Text = "asdfasdfasdfasdfasdfasdf"
myTB.TextFrame.Characters(Start:=1, Length:=23).Font.Name = "Arial"



MarkCR wrote:

Hi Dave:

Thanks for your response. It seemed like the right answer, but I am getting
the same error on the line:

myTB.OLEFormat.Object.Characters(Start:=1, Length:=23).Font.Name = "Arial"

Very strange...
Mark

"Dave Peterson" wrote:

From what I've read in the newsgroup, xl2007 has trouble when you select shapes.

Maybe you could do it without the selection:

Dim myTB As Shape
Set myTB = ActiveChart.Shapes.AddTextbox _
(msoTextOrientationHorizontal, 500, 80, 120, 60)

myTB.OLEFormat.Object.AutoScaleFont = False
myTB.OLEFormat.Object.Characters(Start:=1, Length:=23).Font.Name = "Arial"


--

Dave Peterson


All times are GMT +1. The time now is 07:31 PM.

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