My User form captures the screen print of the window and pastes it in a word document. But I wanted to apply a thick border of color red/black to the image as soon as I paste the image. After googling I found that we can use InlineShapes in VBA to apply picture borders and tried the below code, but this throws me an error 'Variable not found'.

Can anyone help to get this sorted out?

Code:

sub captureAndPasteWindow()

keybd_event VK_SNAPSHOT, 0, 0, 0

WordObj.Selection.Paste

WordObj.Selection.InlineShapes(1).Select

With Selection.InlineShapes(1)
.Line.BackColor = vbBlack
.Line.Weight = 20
.Line.Style = msoLineSingle
End With

End Sub

- Captain Cool