Can i have a macro that will create a screen shot of my selected window and save it in a folder
Asked
Active
Viewed 220 times
1 Answers
1
Stolen shamelessly (but tested) from here:
Sub test()
Dim cht As Chart
With Range("A1:E10")
.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Set cht = ActiveSheet.ChartObjects.Add(10, 10, .Width, _
.Height).Chart
End With
cht.Paste
cht.ChartArea.Border.LineStyle = 0
On Error Resume Next
Kill "testChart.jpg"
On Error GoTo 0
cht.Export "testChart.jpg", "jpg"
cht.Parent.Delete
End Sub
I assume you mean selected Range
, not window, else a keystroke will do. We need to replace Range("A1:E10")
with Selection
, and wrap it in an error check, because Selection
s are a little risky