ElJamoquio
09-09-2017, 10:16 AM
Hello, and apologies! I'm a complete newbie to VBA.
I'm trying to create a macro to paste and automatically resize an image that's on my clipboard. I've found similar macros on the web, but as a complete newbie to VBA I'm not able to do what I want.
Here's one example:
On Error Resume Next
Dim oShp As Shape
Dim iShp As InlineShape
Dim ShpScale As Double
'Selection.Paste (here I tried to paste it, didn't seem to work)
With Selection
For Each iShp In .InlineShapes
With iShp
If .Type = wdInlineShapePicture Or wdInlineShapeLinkedPicture Then
ShpScale = InchesToPoints(4) / .Width
.Width = .Width * ShpScale
.Height = .Height * ShpScale
End If
End With
Next iShp
End With
Can anybody help? Why wasn't the paste working in the code above? What is recommended - just want to paste in an image with a certain size, seems like that should be relatively straightforward.
I'm trying to create a macro to paste and automatically resize an image that's on my clipboard. I've found similar macros on the web, but as a complete newbie to VBA I'm not able to do what I want.
Here's one example:
On Error Resume Next
Dim oShp As Shape
Dim iShp As InlineShape
Dim ShpScale As Double
'Selection.Paste (here I tried to paste it, didn't seem to work)
With Selection
For Each iShp In .InlineShapes
With iShp
If .Type = wdInlineShapePicture Or wdInlineShapeLinkedPicture Then
ShpScale = InchesToPoints(4) / .Width
.Width = .Width * ShpScale
.Height = .Height * ShpScale
End If
End With
Next iShp
End With
Can anybody help? Why wasn't the paste working in the code above? What is recommended - just want to paste in an image with a certain size, seems like that should be relatively straightforward.