Hi,
I have to create reports and Charts in Excel and then send them to respective managers. Charts must use our corporate color scheme, which is not available in Excel. Thus I've written a code stage in Existing Excel VBO to copy charts to PPT, where the right color scheme is automatically applied, and then save them as images. Everything runs perfectly until it hits an export line - then I get an error HRESULT: 0x80070057 (E_INVALIDARG). Does anybody have any idea why this happens? The PowerPoint code also works perfectly fine in PowerPoint Macro Editor.
I have to create reports and Charts in Excel and then send them to respective managers. Charts must use our corporate color scheme, which is not available in Excel. Thus I've written a code stage in Existing Excel VBO to copy charts to PPT, where the right color scheme is automatically applied, and then save them as images. Everything runs perfectly until it hits an export line - then I get an error HRESULT: 0x80070057 (E_INVALIDARG). Does anybody have any idea why this happens? The PowerPoint code also works perfectly fine in PowerPoint Macro Editor.
Code:
Dim ws as Object = GetWorksheet(handle,workbookname,worksheetname)
ws.ChartObjects(1).Chart.ChartArea.Copy
Dim pptApp as Object
pptApp = CreateObject("PowerPoint.Application")
Dim activePPT as Object = pptApp.Presentations.Open(presPath, 0, 0, -1)
activePPT.Slides(1).Shapes.Paste
activePPT.Slides(1).Shapes(1).ScaleWidth(2, 0)
activePPT.Slides(1).Shapes(1).ScaleHeight(2, 0)
activePPT.Slides(1).Shapes(1).Chart.Export(imgPath, "PNG")
pptApp.Quit