Operating Ms Paint using excel-VBA

邮差的信 提交于 2019-12-24 09:38:02

问题


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:


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...



来源:https://stackoverflow.com/questions/38367064/operating-ms-paint-using-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!