I am running a script to automate working with reports.
We have data from our notification system, and we copy it into an Excel sheet, in which there is a chart.
Then we copy the diagram from the excel sheet into a text document.
It is not so difficult until you think about the fact that we do this for ~ 50 servers every month.
I was able to automate dumping data into an Excel spreadsheet with a chart in it and updating the chart. I am stuck in copying and pasting charts from Excel to Word:
$xl = new-object -comobject excel.application $xl.Visible = $true $wb = $xl.workbooks.open("C:\blah\Servername_graph.xlsx") $ws = $wb.worksheets.item(1) $charts = $ws.ChartObjects() $chart = $charts.Item(1) $a = $chart.copy $wd = new-object -comobject Word.application $wd.visible = $true $path = "C:\blah\doc.docx" $doc = $wd.documents.open($path)
As you can see from the code, I open the excel sheet by selecting the chart and copying it. I open a document, but donβt know how to insert it.
source share