-1

Can i have a macro that will create a screen shot of my selected window and save it in a folder

Community
  • 1
  • 1
saikri
  • 147
  • 1
  • 1
  • 12

1 Answers1

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 Selections are a little risky

Community
  • 1
  • 1
Ioannis
  • 5,238
  • 2
  • 19
  • 31