Save Picture of Excel Table Out of Excel into a Folder

dec789

New Member
Joined
Aug 17, 2015
Messages
7
I'm using the below code to save a picture of an Excel table in the workbook on Sheet1 (thank you JoeMo for the help).
The next thing I would like to do is save that picture to a folder for use in other applications (most likely display in a web page via SharePoint).
Is this even possible?
Thanks in advance for your time.


Code:
Option Explicit

Sub MacroX()

    Dim sWrkBkName As String
    sWrkBkName = Application.ActiveWorkbook.Name

    Worksheets("CA Info").Range("C3:I142").CopyPicture xlScreen, xlBitmap
    With Worksheets("Sheet1")
           .Select
           .Paste Destination:=Worksheets("Sheet1").Range("A1")
           Selection.Name = Left(sWrkBkName, Len(sWrkBkName) - 5)
    End With

End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Put this in your macro:
Code:
    Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "C:\Path\to\folder\Excel_cells.png"  'change path and file name as required
and add this to the module:
Code:
Public Sub Save_Object_As_Picture(saveObject As Object, imageFileName As String)

    'Save a picture of an object as a JPG/JPEG/GIF/PNG file
    
    'Arguments
    'saveObject     - any object in the CopyPicture method's 'Applies To' list, for example a Range or Shape
    'imageFileName  - the .gif, .jpg, or .png file name (including folder path if required) the picture will be saved as
    
    Dim temporaryChart As ChartObject
     
    Application.ScreenUpdating = False
    
    saveObject.CopyPicture xlScreen, xlPicture
    
    Set temporaryChart = ActiveSheet.ChartObjects.Add(0, 0, saveObject.Width + 6, saveObject.Height + 6)
    With temporaryChart
        .Border.LineStyle = xlLineStyleNone      'No border
        .Chart.Paste
        .Chart.Export imageFileName
        .Delete
    End With
    
    Application.ScreenUpdating = True
    
    Set temporaryChart = Nothing
    
End Sub
 
Upvote 0
John_w - Thank you so much that worked perfectly. I really appreciate you taking the time to help me with this.
Thanks again!
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,963
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top