Cuinn Herrick

Exporting an image (png) to clipboard

Discussion created by Cuinn Herrick on Dec 11, 2018
Latest reply on Dec 13, 2018 by Mike Spens

I have created a macro that exports an image from SolidWorks to file and then copies it to the clipboard using Microsoft Excel in the background. This allows me to then quickly paste the image into emails and documents.

    Dim xl As Object

    Dim xlsh As Object

    Dim sh As Object

    Set sh = CreateObject("Excel.Application")

    Set xl = GetObject(, "Excel.Application") ' Excel is open

    xl.Workbooks.Add (xlWBATWorksheet)


    Set xlsh = xl.ActiveSheet

    xlsh.Pictures.Insert(Left(swModel.GetPathName, InStrRev(swModel.GetPathName, ".") - 1) + ".png").Select


Can anyone recommend a more elegant way of doing this without saving the image or needing excel? I have look all over for a native solution but copying an image directly to the clipboard seems to be asking a lot more than just copying text.


Otherwise, please enjoy the attached macro.