Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting the formula from a linked autoshape 1

Status
Not open for further replies.

asrisk

MIS
Nov 27, 2003
105
GB
In Excel, you can assign a formula to an Autoshape, so that it displays the value of a reference. Is it possible to read this formula back using VBA? I tried to use the construction Autoshapes("name").textframe.characters.text, but this returns the result of the formula (i.e. what is displayed in the autoshape) not the formula itself.

I used the macro recorder to record myself applying a formula, and the captured code was ExecuteExcel4Macro("FORMULA"), which does not help much in how I might read this back.

(Background: I am trying to write a macro to find all references where a particular named range is used. I've done cell formulae, chart series and references within other named ranges, but want to check autoshape formulae too.)

Thanks in advance

Andy.

-------
The joke cannot be found
[sup]The funny quote you are looking for might have been removed, had its name changed, or is temporarily unavailable.[/sup]
 
MsgBox Worksheets(1).Shapes(1).DrawingObject.Formula

combo
 
Perfect, combo - just what I was looking for, thank you.

It only remains a mystery as to why "DrawingObject" turns up a blank in Help, and is not listed as a property or method of the Shape object!

Oh well. Thanks again!

-------
The joke cannot be found
[sup]The funny quote you are looking for might have been removed, had its name changed, or is temporarily unavailable.[/sup]
 
It is a part of hidden interface - right-click 'members' part of object browser and tick 'show hidden members' to reveal it. There is 'DrawingObject' property of 'Shape' and 'Drawing' class. Nb. this can be used to set formula too.

combo
 
So it is. There's another thing I've learned today! :cool:

Cheers
Andy.

-------
The joke cannot be found
[sup]The funny quote you are looking for might have been removed, had its name changed, or is temporarily unavailable.[/sup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top