?
Solved

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

Posted on 2011-09-23
4
Medium Priority
?
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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