Solved

Specify the top property of a text box added to a chart.

Posted on 2011-09-23
4
168 Views
Last Modified: 2012-05-12
Dear Experts:

Below code adds a textbox to the active chart.
 
activechart.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 120, 100 ,20).TextFrame.Characters.Text = "Hello"
'1. Value = Left property of textbox = 20 points
'2. Value = Top property of textbox = 120 points

I wonder whether it is possible to specify the ...
Top property of the textbox relative to the Height property of the active chart.

For example: I do not want to specify the Top Property as 120 points but as being  90% percent of the Height property of the active chart.

Is this possible?

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
0
Comment
Question by:AndreasHermle
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 36585877
Andreas - I had a play and this did something - is it what you want? You could always try experimenting with the numbers:
With ActiveChart.Shapes.AddTextbox(msoTextOrientationHorizontal, 20, 120, 100, 20)
    .TextFrame.Characters.Text = "Hello"
    .Left = 20
    .Top = ActiveChart.ChartArea.Height * 0.9
End With

Open in new window

0
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36585941
I must say I'm not quite sure why this appears to work as it does, can't see why the position of the text box and the chart should be linked.
0
 

Author Comment

by:AndreasHermle
ID: 36586105
Hi Stephen,

.... can't see why the position of the text box and the chart should be linked.
That's what I thought as well when I first saw this snippet in some excel forum. But the original code works great, so DOES your TWEAK!

Thank you very much for your professional help. Regards, Andreas

0
 

Author Closing Comment

by:AndreasHermle
ID: 36586108
As always, great job and swift support from your side.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now