-3

I am working on an Excel file and I need a macro that takes a screenshot of just cells G3 to J14 of the current sheet and saves it as an image file (any common format will do) to the folder containing the Excel file with a file name matching the contents of cell B3.

Community
  • 1
  • 1
qwertyu63
  • 105
  • 1
  • 5
  • 2
    Have to point out that I don't quite see a question in your posting. Please remember that SO is not a code writing service but rather a forum to get pointed advise on coding errors. You can start with looking a this posting on how to paste as picture and go from there: http://stackoverflow.com/questions/14990503/excel-macro-take-a-snapshot-of-particular-range. Once you have your code if you have any specific issue you can post it here to get help. Regards – nbayly Sep 26 '16 at 21:45
  • Here is another posting that I found after a Google search that specifies code to save a picture from clipboard to the file system: http://www.vbaexpress.com/forum/showthread.php?25275-Saving-Clipboard-data-as-picture. With both of these links you should be able to figure out what you need. – nbayly Sep 26 '16 at 21:49

1 Answers1

0

This appears to work:

Sub Macro1()
    myFileName = "chrt.png"
    Range("G3:J14").Select
    Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

    Charts.Add
    ActiveChart.Paste
    ActiveChart.Export Filename:=ThisWorkbook.Path & "\" & myFileName, Filtername:="PNG"
End Sub

But you may need to resize or edit the resulting picture to meet your needs. You also may want to delete the Chart when you are done.

Gary's Student
  • 95,722
  • 10
  • 59
  • 99