Saving picture from Excel to SharePoint

dec789

New Member
Joined
Aug 17, 2015
Messages
7
In the two subroutines at the bottom of this post I am able to save a .gif from a workbook to a normal network folder but when I attempt to save to a SharePoint folder the code error out.
These two lines of code...
Code:
    Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "\\Share01\sp\CSM_Systems_Admin\Frame35.gif"
    Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "http://ssvc30-ap0238/ASeCSRR/F35/Workbooks/Frame35.gif"
are from the code blocks below the first one works but when I try the second one (a SharePoint) folder the line
Code:
.Chart.Export imageFileName
throws the error below.
Can anyone tell me what I'm doing wrong? I know very little about SharePoint only that the Company wants us to start migrating to it.

"ERROR MESSAGE"
Run-time error -2146697210 (800c0006):
Method Export of object _Chart failed

Code:
Sub SaveImageToSharePoint()
    Dim sWrkBkName As String
    sWrkBkName = Left(Application.ActiveWorkbook.Name, Len(Application.ActiveWorkbook.Name) - 5)
    
    'Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "\\Share01\sp\CSM_Systems_Admin\Frame35.gif"
    Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "http://ssvc30-ap0238/ASeCSRR/F35/Workbooks/Frame35.gif"
    MsgBox "Image has been submitted. Done."
End Sub

Public Sub Save_Object_As_Picture(saveObject As Object, imageFileName As String)

    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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
NOTE: Regarding the two subroutines posted... I have a similar set of subroutines where I can successfully save a whole Excel workbook to the same SharePoint path I'm trying to save the .gif to and it works perfectly.
The SharePoint path I'm using to save the workbook to and the .gif to: "http://ssvc30-ap0238/ASeCSRR/F35/Workbooks/Frame35.gif" - I can save the workbook but the .gif throws the error.
 
Upvote 0
If anyone is interested I did some further testing and the line of code below seems to work for me.
It seems too easy.
Code:
Save_Object_As_Picture Worksheets("CA Info").Range("C3:I142"), "\\ssvc30-ap0238\ASeCSRR\F35\Workbooks\Frame35.gif"
 
Upvote 0
Not really, the first way tries to save over http, you can't do it like that, you can save to a network share though as you've found in your second approach though
 
Upvote 0

Forum statistics

Threads
1,216,049
Messages
6,128,496
Members
449,455
Latest member
jesski

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