+ Reply to Thread
Results 1 to 5 of 5

Help with Chart to PNG export macro needed.

  1. #1
    Registered User
    Join Date
    11-06-2014
    Location
    Ireland
    MS-Off Ver
    2007
    Posts
    3

    Help with Chart to PNG export macro needed.

    Hi all,

    first please let say that I am new to VBA, but have some basic knowledge about macros so apologies in advance if I will be asking silly questions or using incorrect terms.

    Now, I am working on a macro that will export all charts from two specific worksheets called "YTD Graphs" and "MTD Graphs"
    I was able to put together macro below, but it exports charts only from "MTD Charts" sheet (Chart Tools displayed on top of the workbook when "MTD Graphs" sheets is active).

    Both sheets have 9 graphs in them that need to be exported. For now graphs are being exported into file source folder. Later I would like to add prompt for users to select path or subfolder.

    So at the moment only "MTD Graphs" are being exported and I can't make the "YTD Graphs" to work.

    Unfortunately I can't attach the Workbook for you to have a look due to data sensitivity.

    Please Login or Register  to view this content.
    I was thinking about using
    Please Login or Register  to view this content.
    to directly set sheets that I want the macro work with or at least somehow activate "YTD Graphs" sheet.

    Thanks in advance for your help.

    Tom

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Help with Chart to PNG export macro needed.

    Your code actually processes all worksheets, but it should error because you try to activate charts without activating the parent sheet first. You are also saving all the pictures with an MTD prefix.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    11-06-2014
    Location
    Ireland
    MS-Off Ver
    2007
    Posts
    3

    Re: Help with Chart to PNG export macro needed.

    Hi romperstomer,

    thank you for your reply.

    The code doesn't trigger eny error at all.

    Our report file has some 20-ish Worksheets and charts that I need to export are in Worksheets called "YTD Graphs" and "MTD Graphs". I wanted to make sure that if there would be any other charts in the rest of the Worksheets that they get exported too.

    Idea was that first part of the code exports all charts that are in their own sheets and the second part of the code should export charts that are embedded inside normal sheets.

    When it comes to refixes, I intended to save charts from "YTD Graphs" worksheet with "YTD" prefix and charts from "MTD Graphs" with "MTD" prefix to distinquish them.

    Tom

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Help with Chart to PNG export macro needed.

    Quote Originally Posted by mileater View Post
    Idea was that first part of the code exports all charts that are in their own sheets and the second part of the code should export charts that are embedded inside normal sheets.
    That is exactly what it does. (although, as I said, it names them all with "MTD" currently, regardless of sheet). If you don't get an error and don't get any other exports, then either there aren't any charts on the other sheets, or the wrong workbook is active.

  5. #5
    Registered User
    Join Date
    11-06-2014
    Location
    Ireland
    MS-Off Ver
    2007
    Posts
    3

    Re: Help with Chart to PNG export macro needed.

    Good point! I was so focused if I did the coding right and was thinking that something is wrong with it that I completely overlooked this aspect.

    The charts in the "YTD" were not in fact charts, but images. That explains why I did not get any errors and no exports from that sheet either.

    So thank you romperstomper for pointing that out to me!

    I now got updated file from analysts and both "YTD" and "MTD" sheets now contain charts that are being exported properly.

    I am feeling silly for not double checking such basic thing.

    Now I have to ensure that exported PNGs have refix of the Worksheet that they were exported from and implement dialog box asking users to select path to save the images.

    Do you guys have an idea how to do something effective in my macro? Any help is very appreciated.

    Thank you.

    Tom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help Needed : Macro to click on "Export to excel" tab
    By Elangovan89 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-24-2014, 07:35 AM
  2. Writing a macro to create a chart help needed
    By kingdoz in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-12-2014, 03:04 PM
  3. [SOLVED] VBA/Macro help needed for Mail Merge in Excel and export each record as PDF format
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-28-2013, 06:33 AM
  4. Macro assistance needed for complex export/import excel file
    By dedavie in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-28-2013, 02:47 PM
  5. [SOLVED] Simple macro needed to export a worksheet
    By RobG in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-12-2005, 05:12 AM

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