PDA

View Full Version : Add border to selected shape in Outlook



cr731
12-09-2015, 11:33 AM
I would like to create a macro that will,

1. Test if a shape is selected.
2. If yes, put a black border around the selected shape.

I'm not familiar with VBA in Outlook; can anyone point me in the right direction?

Thanks

gmayor
12-09-2015, 11:33 PM
The following will add a 1.5 point border around a selected inserted inline image.


Sub AddBorder()
Dim oShape As Object
On Error GoTo ErrHandler
If TypeName(ActiveWindow) = "Inspector" Then
If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
If ActiveInspector.WordEditor.Application.Selection.InlineShapes.Count > 0 Then
Set oShape = ActiveInspector.WordEditor.Application.Selection.InlineShapes(1)
oShape.Borders(-1).Color = &H0& 'Black
oShape.Borders(-1).LineWidth = 12 '1.5 points
oShape.Borders(-2).Color = &H0&
oShape.Borders(-2).LineWidth = 12
oShape.Borders(-3).Color = &H0&
oShape.Borders(-3).LineWidth = 12
oShape.Borders(-4).Color = &H0&
oShape.Borders(-4).LineWidth = 12
End If
End If
End If
lbl_Exit:
Exit Sub
ErrHandler:
Beep
Err.Clear
GoTo lbl_Exit
End Sub