How to copy Excel pivot charts to an email using PowerShell RRS feed

جميع الردود

  • Use the "Range" "Copy" command on the Chart object you wish to copy.  Outlook MailItems have a "Paste" that will insert the chart at the current location.

    Search for examples.  There are many in C# and some in PowerShell.


    16/صفر/1441 08:50 م
  • Here is the Excel code to copy a chart with data as a picture.

    $wb.Worksheets['Sheet4'].ChartObjects('Chart 2').CopyPicture()


    16/صفر/1441 09:27 م
  • I just saw that you really were asking to copy a Pivot Table and not a chart. This is the command to copy a PT.



    17/صفر/1441 03:31 ص
  • Thank you very much, I am unable to get the chart, it is null when pasted to an email any suggestion would be much appreciated!

    $xl = new-object -comobject excel.application 

    $wb = $"PATH.xlsx")
    $ws = $wb.worksheets.item("Sheet1")
    $image = $ws.ChartObjects().copyPicture()
    $chart = $ws.Selection.PasteSpecial()

    17/صفر/1441 04:36 ص
  • You have to paste it into a mail item. Open Outlook and create a new mail item in the GUI them run the copy then go to the mail item and use Ctrl-V to paste. This will tell you if you have successfully copied the charts. Your code is not right. You must follow my code exactly or you will get nothing.

    The code you are using cannot copy a pivot table and you must get it by name or you must enumerate the objects in a loop and copy each one individually.

    Using Office automation in this way may be too technical for a non-programmer.  It is not like using PowerShell commands.  You must understand the object models in use.


    17/صفر/1441 05:24 ص
  • Got it but it is actually chart is what am trying to copy.
    17/صفر/1441 03:40 م
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    22/صفر/1441 07:56 ص