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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through all worksheets & return chart title

Status
Not open for further replies.

tigersden

Technical User
Apr 16, 2003
81
0
0
GB
Hi,
I am new to Excel VBA & need some help.
I am trying to loop through all worksheets in a workbook.
Each worksheet has a graph in it, I need to get each charts title & then build a TOC with the returned charts titles.
Thanks in advance
Tim
 


Hi Tim,

You need to look at the Excel Object Model. It will help you conceptualize how Excel Objects are used.
Code:
    Dim ws As Worksheet, cho As ChartObject
    For Each ws In ActiveWorkbook.Worksheets
      For Each cho In ws.ChartObjects
        MsgBox cho.Chart.Name
      Next
    Next


Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
Hi Skip,

Thanks for that, but is it possible to actually get the charts Title not name?

Tim
 


did you EXPERIMENT at all??

How about ChartTitle instead of Name? This is where the Object Model will help you.
Code:
MsgBox cho.Chart.ChartTitle.Text

Skip,
[sub]
[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue][/sub]
 
Tim - this is not a helpdesk.

People are more than happy to help and give advice but the ethos here is on learning. Skip gave you some hints about where you can start learning about the chart object within the excel object model - it is up to you to experiment with what has been given and to then post if you have difficulties utilising what has been posted - showing what you have tried and where it has failed.

Whilst you may occasionally get a full answer here, do not expect it - we are not here to do your work for you - we are here to help you LEARN.

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Hi Skip & xlbo,
My fault I should have mentioned I had tried to get the chart title but missed .text from my effort.
I do not expect you to do my work for me, in future I will ensure that I make it crystal clear what I have tried & what did not work.
Any way thanks for your help Skip

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top