10

Here's something which has been annoying me for months, if not years. When I paste an image into an Outlook email, it has no borders. I can add these by right-clicking on the picture and choosing Format Picture, and there's probably a tool to do this too. My question is: is there a way to ensure that all pasted images have borders? If there was a CSS style sheet for Outlook, I could do this here; or maybe there's a setting somewhere?

Thanks in advance!

2 Answers 2

7

I've got a Word 2010 macro that adds a border to images and center them:

Sub AddBlueBorderAndCenterImages()
    Dim oIshp As InlineShape
    Dim oshp As Shape

    For Each oIshp In ActiveDocument.InlineShapes 'in line with text
        With oIshp.Borders
            .OutsideLineStyle = wdLineStyleSingle
            .OutsideLineWidth = wdLineWidth025pt
            .OutsideColor = RGB(0, 112, 192)
        End With
        oIshp.Select
        Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Next oIshp

    For Each oshp In ActiveDocument.Shapes 'floating with text wraped around
        With oshp.Line
            .Style = msoLineSingle
            .Weight = 0.25
            .ForeColor.RGB = RGB(0, 112, 192)
        End With
    Next oshp

    Selection.HomeKey Unit:=wdStory 'go back to top of doc
End Sub

I've tried adapting it to Outlook, the main thing is trying to get to Word's ActiveDocument from an Outlook item.

So here is the Outlook version (without any centering):

Sub AddBlueBorders()
    Set insp = Application.ActiveInspector
    If insp.CurrentItem.Class = olMail Then
        Set mail = insp.CurrentItem
        If insp.EditorType = olEditorWord Then
            Set wordActiveDocument = mail.GetInspector.WordEditor

            For Each oIshp In wordActiveDocument.InlineShapes 'in line with text
                With oIshp.Borders
                    .OutsideLineStyle = wdLineStyleSingle
                    '.OutsideLineWidth = wdLineWidth025pt ' error: one of the values passed to this method or property is out of range
                    .OutsideColor = RGB(0, 112, 192)
                End With
            Next oIshp

            For Each oshp In wordActiveDocument.Shapes 'floating with text wraped around
                With oshp.Line
                    .Style = msoLineSingle
                    .Weight = 0.25
                    .ForeColor.RGB = RGB(0, 112, 192)
                End With
            Next oshp

        'ElseIf insp.EditorType = olEditorHTML Then
        'Something else here, maybe using css?

        End If
    End If
End Sub

For some reason, this doesn't add a border to a company logo I have in my signature, maybe because it's in a footer or other document part.

This is not a default and it's not automatically adding borders to images as they are pasted/added to the email. You still have to associate this macro with a button or key shortcut. But hopefully it will help, even 4 months later.

Vaguely inspired from http://en.allexperts.com/q/Microsoft-Word-1058/Word-resize-pictures.htm

2
  • I don't seem able to accept this answer or award the bounty, which is a shame, as it works! Presumably I must be using Word as my Outlook editor. Thanks so much - you've changed my life!
    – Andy Brown
    Feb 15, 2013 at 9:43
  • This is great! Valid values for OutsideLineWidth which I noticed you commented out are here: learn.microsoft.com/en-us/office/vba/api/word.wdlinewidth (e.g., wdLineWidth300pt)
    – d0g
    Jul 23, 2021 at 16:28
1

You could consider to provide a VBA macro (plus key short-cut to it). Not sure how this works for image borders, but for selected in email text here is a simple example:

Sub ChangeSelectedExample()
    Set insp = Application.ActiveInspector
    If insp.CurrentItem.Class = olMail Then
        Set mail = insp.CurrentItem
        If insp.EditorType = olEditorHTML Then
            txt = ActiveInspector.HTMLEditor.Selection.CreateRange.Text
                  ActiveInspector.HTMLEditor.Selection.CreateRange.Text = txt & "<hello world 1>"
        ElseIf insp.EditorType = olEditorWord Then
            txt = insp.CurrentItem.GetInspector.WordEditor.Application.Selection.Text
                  insp.CurrentItem.GetInspector.WordEditor.Application.Selection = txt & "<hello world 2>"
        Else
            MsgBox ("not supported mail format")
        End If
    Else
        MsgBox ("not supported view type")
    End If
End Sub
2
  • I tried developing this idea, having added variables: Dim insp As Inspector Dim mail As MailItem Dim txt As String However, I can't see how to get at a picture. Thanks for the idea - any idea how to make it work?
    – Andy Brown
    Sep 24, 2012 at 15:23
  • Thanks for the idea, but I can't award the "bounty" (first time I've used it), as it doesn't solve the problem. Maybe it will be applied automatically? Not sure how the system works.
    – Andy Brown
    Sep 28, 2012 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.