Eawyne
Board Regular
- Joined
- Jun 28, 2021
- Messages
- 53
- Office Version
- 2021
- Platform
- Windows
Hiyall,
I'm trying to automate a screenshot button that resizes the image and then cuts it so it can be pasted into a mail. Here's the code I have that does just that (taking the snap, pasting it in Excel, do stuff on the shape and then cutting it - see uploaded image) :
But the problem is that the size is a bit too large for a mail, and setting up heigh and weight do so on an absolute manner, from top and left ; I would like to make it crop around the center of the image (as regardless of the screen, the Form always shows up in the middle of it). Is there a way to do this ?
I'm trying to automate this process, as people tend not to do the required screenshot for those important mails. As it appears it's impossible to emulate a Win keystroke, thus preventing the use of Snip and Sketch via a VBA button, I tried to come up with another solution. Maybe could there be another solution (that doesn't require the use of APIs, which would be a no no on the intranet at my company).
PS : I tried to post a sample file, but I didn't seem to find a possibility ? ^^'
I'm trying to automate a screenshot button that resizes the image and then cuts it so it can be pasted into a mail. Here's the code I have that does just that (taking the snap, pasting it in Excel, do stuff on the shape and then cutting it - see uploaded image) :
VBA Code:
Sub CopyScreen()
Application.SendKeys "({1068})", True
DoEvents
ActiveSheet.Paste
Dim shp As Shape
With ActiveSheet
Set shp = .Shapes(.Shapes.Count)
End With
Dim h As Single, w As Single
'h = -(600 - shp.Height)
'w = -(800 - shp.Width)
shp.LockAspectRatio = False
shp.PictureFormat.CropRight = w
shp.PictureFormat.CropBottom = h
'shp.Cut
End Sub
But the problem is that the size is a bit too large for a mail, and setting up heigh and weight do so on an absolute manner, from top and left ; I would like to make it crop around the center of the image (as regardless of the screen, the Form always shows up in the middle of it). Is there a way to do this ?
I'm trying to automate this process, as people tend not to do the required screenshot for those important mails. As it appears it's impossible to emulate a Win keystroke, thus preventing the use of Snip and Sketch via a VBA button, I tried to come up with another solution. Maybe could there be another solution (that doesn't require the use of APIs, which would be a no no on the intranet at my company).
PS : I tried to post a sample file, but I didn't seem to find a possibility ? ^^'