Hello dear people,
I'm here because I need your help once again.
I tried to save a screenshot of an UserForm, after a search I achieved something using the following code:
When I Press "Alt+Impr Pant" in my keyboard, it take a screenshot just of the UserForm I have open in that moment, that's what I need; After I press a button which has the following code to save the image:
Sub SaveFormImg_Click()
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
ws.Paste
'Range("A1").Paste
Dim oDia As Object
Dim oChartArea
Dim sh As Shape
Dim PicName As String
For Each sh In ws.Shapes
PicName = Fname
sh.CopyPicture
Set oDia = ws.ChartObjects.Add(0, 0, sh.Width, sh.Height)
Set oChartArea = oDia.Chart
oDia.Activate
With oChartArea
.ChartArea.Select
.Paste
.Export (fPath & PicName & "D:\My Files\Test.jpg")
End With
oDia.Delete
sh.Delete
Next
End Sub
I'm here because I need to modify three things in this code, but I haven't succeeded
1. How I can integrate the "Alt+Impr Pant" action in the code? In that way I can skip this action before press the button and the button will perform all the work. I already tried "SendKeys" but I supposed I don't have the enough knowledge to integrate it.
2. The image is saved larger than expected, I mean, it don't respect the original size of the screenshot. I read that I can modify the Paste Section implementing "Width= -1" and "Height= -1" but I failed to implement it.
3. As you can see in the code, the file is saved with the name "Test.jpg", How I can make the image save with the same name of the Workbook?
I hope you can help me!
Thank you so much!
Bookmarks