0

I copied a code given in a different thread and modified it to fit my file. But now, I'm using MacOS.

I don't know how to change this Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "Capture.jpg" for MacOS.

The code allows me to copy a range in an excel file then paste the copied range as a photo in a separate sheet. Then export or save it as "Capture.jpg" in Windows Desktop.

Dim aChart As Chart, Rng As Range, Path As String

    Path = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & "Capture.jpg"
    Set Rng = Range("E1:F54")

    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)
        Rng.CopyPicture
        Application.DisplayAlerts = False
        .Delete
        Application.DisplayAlerts = True
    
    End With
Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
  • See what I did: https://stackoverflow.com/q/30575923/4961700 – Solar Mike May 19 '22 at 09:51
  • Does the way you try raise an error? If so, this is not connected to the path itself, I think. If no any error (on the shown code line), try replacing the Backslash (\\) with Slash (`/`)... – FaneDuru May 19 '22 at 09:51
  • @FaneDuru `WScript.Shell` does not work with mac. See link above the question. – Pᴇʜ May 19 '22 at 09:55
  • @Pᴇʜ In fact, I supposed that. I remembered a discussion on a similar issue, but I was not sure that it was about "WScript.Shell". That's why the sibilinic way of identification the problem root... :) – FaneDuru May 19 '22 at 10:03

0 Answers0