+ Reply to Thread
Results 1 to 6 of 6

Auto size and remove borders from Excel charts

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Auto size and remove borders from Excel charts

    Hey people!
    I need help with my VBA code, because I have got stuck at one point. I have a code that creates a .png image of a certain range of the Excel document. The picture is then saved on my computer. When I open the image, it's an ugly line around the entire image and the image is not centered, but placed in the left hand corner.

    I want help to remove the border around the image and to auto-size the chart to fit the image.
    I have this code:
    Sub SaveAsAPic()

    Application.ScreenUpdating = False
    With Charts.Add
    .SetSourceData Source:=Sheets("groups").Range("A1")
    Do While .SeriesCollection.Count > 0
    .SeriesCollection(1).Delete
    Loop
    Sheets("groups").Range("A1:I24").CopyPicture Appearance:=xlScreen, Format:=xlPicture
    .Paste
    .Export Filename:="C:\gruppsel" & ".png", FilterName:="PNG"
    End With

    Application.DisplayAlerts = False
    ActiveWorkbook.Charts.Delete
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True


    End Sub
    Here's the picture:
    NEW_PICTURE.gif

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Auto size and remove borders from Excel charts

    Hi,
    This may do what you want
    Please Login or Register  to view this content.
    Good luck.

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto size and remove borders from Excel charts

    Thx m8 for the quick reply!
    You solved the problem with the size but the border is still there: (
    Can you help me with it?
    Last edited by 2lkopp3n; 01-09-2012 at 09:57 AM.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Auto size and remove borders from Excel charts

    I think so - try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-09-2012
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto size and remove borders from Excel charts

    wow! You solved my problem in minutes that I have spent hours on
    thanks so much

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Auto size and remove borders from Excel charts

    You are welcome. That is why sites like this exist, after all.

+ 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