Thank you for your time. So this code pastes the screenshot into a folder in Desktop? Is there a way to have it just copy it to the clipboard?
VBA to Take Screenshot of Range
Do you mind helping me with a code that will take a screenshot of a range, say, range A1:C10? All the examples I found online were other people doing a lot more than just a simple screenshot (e.g., pasting it into a different range, creating other worksheets to paste there, opening Word and pasting it there, etc.)—way more than I need. I'm no VBA expert and am having difficulty weeding out the code parts I don't need from those examples. I just need it to do the screenshot; I would then (manually) paste it into a specific section of a Word template I use. I can assign the VBA macro to a button in Excel.
Thank you in advance for any help.
Microsoft 365 and Office | Excel | For business | Windows
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
9 answers
Sort by: Most helpful
-
Anonymous
2024-02-19T17:02:18+00:00 -
Anonymous
2024-02-28T06:58:25+00:00 Hi,
try this..
select a range and copy to clipboard as picture
[Update-2]
Sub RangeAsPic_Clip()
' ## 28/02/2024 ##
Dim rng As Range
Set rng = Selection
If MsgBox("select a range ??", vbOKCancel) = vbCancel Then Exit Sub
rng.CopyPicture xlScreen, xlPicture
SendKeys ("{ESC}")'new line
End Sub
=====================
also,
select a shape and copy to clipboard
Sub Shape_to_Clip()
'## 28/02/2024 ##
Dim v As Object
Set v = Selection
If TypeName(v) = "Range" Then
MsgBox "wrong, select a shape"
Else
v.Copy
SendKeys ("{ESC}")
End If
End Sub
-
Anonymous
2024-03-26T15:05:29+00:00 Thank you. When I paste the 'picture' to, say, Word or Outlook, it only pastes a table that isn't editable. With normal screenshots, I add a glow formatting to make it stand out from the background and indicate it's a screenshot. But doing that after using that code highlights everything in the 'picture' rather than just the edges like normal. I still need to find a way to take an actual screenshot via VBA macro. Is this possible?
-
Anonymous
2024-03-31T09:05:40+00:00 Sorry, but I can't help.
I don't understand your question.