VBA Code to save picture file to SharePoint Location - need path vba code

mriggle78

New Member
Joined
Jul 29, 2024
Messages
1
Office Version
  1. 2021
Platform
  1. Windows
I found the below code which saves a picture to my desktop but I would like to change the path so that it saves to a SharePoint drive location. Just wondering how you would write the path code for this differently as the path is typically an https:// file extension. Thanks for the help!

VBA Code:
Sub CopyRangeToJpeg()
    Dim aChart As Chart, Rng As Range, Path As String
    Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "Capture.jpg"
    Set Rng = Sheets("TABLE").Range("C2:G57")

    Call Rng.CopyPicture(xlScreen, xlPicture)
    With Sheets.Add
        .Shapes.AddChart
        .Activate
        .Shapes.Item(1).Select
        Set aChart = ActiveChart
        .Shapes.Item(1).Line.Visible = msoFalse
        .Shapes.Item(1).Width = Rng.Width
        .Shapes.Item(1).Height = Rng.Height
        aChart.Paste
        aChart.Export (Path)
        Application.DisplayAlerts = False
        .Delete
        Application.DisplayAlerts = True
    End With
    MsgBox "Saved to " & vbCr & Path, vbInformation, ""
End Sub
 
Last edited by a moderator:

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
AFAIK all you need is the server path (UNC path). This is not the same as the url of the page or folder that it displays. It begins with \\ and then the server name, then the regular folder path structure.
If you can map a drive to it (using File Explorer, e.g. map "M:" ) the server path will be in the properties dialog box for the drive you map to it.
 
Upvote 0

Forum statistics

Threads
1,223,933
Messages
6,175,473
Members
452,646
Latest member
tudou

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