+ Reply to Thread
Results 1 to 13 of 13

EXport camera view as png

  1. #1
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    EXport camera view as png

    Hello

    I have a few overlaid charts - I need to export them all as one single image to a png file - can you please help me do this via a vba?

    Ideally a range a2:c60 should be exported to png file using the name from cell d1 - "Screenshot"

    Or woudl be easier to via VBA to use the camera and point to this range and export as PNG?

    Thanks many times!)

  2. #2
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    I found this code but it does nto seem to work:

    Please Login or Register  to view this content.
    not sure why it consist of two separate macros?

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: EXport camera view as png

    ???
    Macros work, you only need to change (in short) the range "B2:H8" to "A2:C60" and "J3" to "D1".
    You can also combine both into one, e.g.:
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    please see my last reply - thanks a lot!)!))
    Last edited by zealot; 11-13-2020 at 03:04 AM.

  5. #5
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    Quote Originally Posted by porucha vevrku View Post
    ???
    Macros work, you only need to change (in short) the range "b2:h8" to "a2:c60" and "j3" to "d1".
    You can also combine both into one, e.g.:
    Please Login or Register  to view this content.
    \\

    fantastic script - this seem to work perfectly

  6. #6
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    can you tell me what this line means?

    with rrng.parent.chartobjects.add(10, 10, 200, 200)

  7. #7
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    The above macro effectively overcomes excels vba limitations and exports a camera image as png using cell value as png name - I just had to move the camera image to a new complete clear worksheet and focus the camera on original overlaid charts


    I now wanted to ask if this macro can be made to export higher resolution chars? I wonder if this line affects image resolution?

    with rrng.parent.chartobjects.add(10, 10, 200, 200)

    I can of course enlarge the camera picture itself but was wondering the VBA can make smaller images with more clarity?
    Last edited by zealot; 11-13-2020 at 03:02 AM.

  8. #8
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: EXport camera view as png

    The code resizes the chartobject to the width and height of the captured range.

    You could try changing the Image Size and Quality setting within the Advanced section of File > Options.
    Cheers
    Andy
    www.andypope.info

  9. #9
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    Thank you Andy - my dpi for image export is set at max 220 dpi - will changing any of these numbers add to image quality?

    with rrng.parent.chartobjects.add(10, 10, 200, 200)

  10. #10
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: EXport camera view as png

    Those values are the dimension of the newly added chartobject, left, top, width, height.
    The code then resizes the chartobject width and height to match the copied image/range size.

    If that setting made no difference to the image quality then I doubt there is anything that you can do to change things.

    You could make then original objects larger so the quality may be better if you then reduce the size of the generated image.

  11. #11
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    thank you Andy - there is a handy service -tinypng.com - the output file from excel is 256 kb png file but when scaled down by tinypng.com it goes down to 70 kb - can enlarge the charts to get better resolution

  12. #12
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    Quote Originally Posted by porucha vevrku View Post
    ???
    Macros work, you only need to change (in short) the range "B2:H8" to "A2:C60" and "J3" to "D1".
    You can also combine both into one, e.g.:
    Please Login or Register  to view this content.

    I am having the following error randomly showing when I loop through the data and try to export like 100 pictures...first this error appears at image number 35 then 78...

    VBA Error 1004 - CopyPicture method of Range class failed


    the following line is highlighted :

    rRng.CopyPicture Appearance:=xlScreen, Format:=xlPicture

    can you please help??? why this can be happening?

  13. #13
    Registered User
    Join Date
    11-09-2006
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    200

    Re: EXport camera view as png

    maybe there is another way to make this macro work or to export the range as png?

+ 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. Return to worksheet from backstage view, i.e. close backstage view or exit backstage view
    By freddyroosevelt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2018, 12:44 AM
  2. Export from Power View
    By Marco1234 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-29-2017, 10:08 AM
  3. Word Opens in DRAFT VIEW. How to open in PRINT LAYOUT view
    By Jenn68 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2017, 06:47 PM
  4. Export power View to Power Point
    By Trinhhai in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 05-09-2014, 05:32 AM
  5. Replies: 3
    Last Post: 08-31-2012, 12:40 PM
  6. Camera
    By UsGrant_75 in forum Excel General
    Replies: 0
    Last Post: 07-12-2006, 09:45 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