Rishi
August 3, 2020, 9:55pm
1
Hi, I’m running into a compiling problem with the following code, can you help solve this please?
Sub CopyAsPicture(Param1)
Application.Range("A6:H14").Select
Application.Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Application.Range("O10").Select
Application.ActiveSheet.Paste
Application.Selection.ShapeRange.LockAspectRatio = msoTrue
Application.Selection.ShapeRange.Height = 106.01778
Application.Selection.ShapeRange.Width = 100.34838
Application.Selection.Copy
Application.Selection.Delete
Application.Range("A6:H14").Select
End Sub
Rishi
August 3, 2020, 10:03pm
2
Never mind, I changed the code to the following and it seems to work without problems.
Sub CopyAsPicture(Param1)
Application.Range("A6:H14").Select
Application.Selection.CopyPicture
Application.Range("O10").Select
Application.ActiveSheet.Paste
Application.Selection.ShapeRange.Height = 106.01778
Application.Selection.ShapeRange.Width = 100.34838
Application.Selection.Copy
Application.Selection.Delete
Application.Range("A6:H14").Select
End Sub
The problem may come from
Application.Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Because parameters must be enclosed between parenthesis ().
So Application.Selection.CopyPicture
will work but also Application.Selection.CopyPicture(xlScreen, xlPicture)
Rishi
August 29, 2020, 4:15pm
4
Sorry for the late reply, I managed to fix it. Thanks for your input!