Solved

Retrieve Excel Chart title formula with vba

Posted on 2011-02-14
3
578 Views
Last Modified: 2012-06-27
Hello,

With Excel 2000,
I need to retrieve chart title formula with vba, or a way to remove the title and later on, set it back as it was before I removed it.

Here is why:
I have a macro that copies all charts in the workbook into a powerpoint presentation.
It all works very well, using
Chart.CopyPicture xlScreen, xlPicture 

Open in new window

and then
mySlide.Shapes.Paste

Open in new window

but for visual reasons, the users want the graph title displayed outside the graph in the powerpoint presentation.

So my simple idea was to read the title, remove it, do the copy/paste, replace the title.

I found that I can get the title by using
Chart.ChartTitle.Caption

Open in new window

.
However, if the title is based on a formula (like "=Page!$E$3") the above property returns the value, not the formula. So I can't set it back as it was before I remove it.

I also tried to remove the title using
Chart.HasTitle=False

Open in new window

, but then the whole ChartTitle object is cleared, along with all formating. So setting it back to true does not set it back as it was.

And unfortunately, the Application.Undo won't work in a macro.

Thanks for any help.
0
Comment
Question by:dapcom
3 Comments
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 200 total points
Comment Utility
The usual method (pre 2007 anyway) is to select the title and then use:
strFormula = ExecuteExcel4Macro("GET.FORMULA(SELECTION())")

Open in new window

0
 
LVL 41

Accepted Solution

by:
dlmille earned 300 total points
Comment Utility
Here's a tip.  I found this searching and this person had very siimilar challenge to what you're faced with.  Apparently, the way it was resolved was by making the font and color of the chart nonviewable.  Later, you can make it more viewable.  In this approach the formula for the title was never altered.

http://www.excelforum.com/excel-charting/758120-return-chart-title-formula-using-vba.html

Please read down the post as the Asker was resolving almost the identical issue.

Dave
0
 
LVL 1

Author Closing Comment

by:dapcom
Comment Utility
Thanks to both of you.

I'll try both the Execute4Excel  and non viewable font font ways tomorrow.

Very helpfull.

It would seem I did not search well enough before posting ;)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

771 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

11 Experts available now in Live!

Get 1:1 Help Now