Operating Ms Paint using excel-VBA

2019-08-03 01:16发布

I've written a code to copy the charts from a worksheet (in my excel workbook) to Ms-Paint and then saving the results.

Sub paintCharts()
ThisWorkbook.Sheets("DesiredData").Activate
With ActiveSheet.ChartObjects.ShapeRange.Group
    .CopyPicture
    .Ungroup
End With
Dim path_Paint As String
Dim paintID As Variant
path_Paint = "C:\Windows\System32\mspaint.exe"
paintID = Shell(path_Paint, vbNormalFocus)
Call AppActivate(paintID)
Call SendKeys("^V")
End Sub

I am getting an error at the Call AppActivate(paintID) further, I want to ask if by calling Call SendKeys("^V") and then Call SendKeys("^S") will do the job.

1条回答
不美不萌又怎样
2楼-- · 2019-08-03 01:46

Does it need to be saved by paint? You can save charts themselves directly.

Just use

Set objChart = ActiveChart 
objChart.Export ("filename.jpg")

Though looking at the date, I assume you figured it out by now...

查看更多
登录 后发表回答