+ Reply to Thread
Results 1 to 2 of 2

Capture chart elements in VB

  1. #1
    obts1434
    Guest

    Capture chart elements in VB

    Is there anyway, if I have an existing chart that is formatted already, to
    capture the all elements of that chart in VB (by recording a macro perhaps)?

    Have a spreadsheet that contains hundreds of charts, all of which are the
    same format, but due to non-adjacent data sources and multiple chart types
    within one chart, it's very tempermental - need to standardize.

    Also, is there a list contained within a spreadsheet of all components of
    that spreadsheet? Primarily trying to capture the chart names to utilize in
    VB coding without having to start recording a macro and then selecting each
    and every chart.

  2. #2
    Jon Peltier
    Guest

    Re: Capture chart elements in VB


    > Is there anyway, if I have an existing chart that is formatted already, to
    > capture the all elements of that chart in VB (by recording a macro perhaps)?


    You want to capture the formats? You can copy a chart, then paste
    special as formats only. This overwrites your chart title and axis
    titles, so in a VBA procedure, you should store these text items in
    string variables, then copy-paste the format, then reapply the titles.

    This might be a use for user-defined chart types, as well:

    http://peltiertech.com/Excel/ChartsH...stomTypes.html

    Again, note that the titles are hosed.

    > Have a spreadsheet that contains hundreds of charts, all of which are the
    > same format, but due to non-adjacent data sources and multiple chart types
    > within one chart, it's very tempermental - need to standardize.
    >
    > Also, is there a list contained within a spreadsheet of all components of
    > that spreadsheet? Primarily trying to capture the chart names to utilize in
    > VB coding without having to start recording a macro and then selecting each
    > and every chart.


    To get a list of chart object names:

    For Each chobChartObject in ActiveSheet.ChartObjects
    Debug.Print chobChartObject.Name
    Next

    To run a macro on each embedded chart

    For Each chobChartObject in ActiveSheet.ChartObjects
    With chobChartObject.Chart
    ' your code goes here
    End With
    Next

    - Jon
    -------
    Jon Peltier, Microsoft Excel MVP
    Peltier Technical Services
    Tutorials and Custom Solutions
    http://PeltierTech.com/
    _______


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1