Consulting

Results 1 to 3 of 3

Thread: Copying Contact Notes with formatting

  1. #1
    VBAX Regular
    Joined
    Feb 2022
    Posts
    9
    Location

    Copying Contact Notes with formatting

    Hello,

    I've been struggling with this for a while now. I need to copy the Notes section of a contact using VBA, preserving formatting.
    Tried using [Contact Item].RTFBody/HtmlBody/GetInspector.WordEditor (I think the last one only works with email body).

    At this point I'm thinking it may not be possible. Does anyone have any experience with this?

    Thanks.

  2. #2
    The word editor works on the body texts of all Outlook items.
    The following will copy the contact notes body to the clipboard
    Sub Macro1()
    Dim olContact As ContactItem
    Dim olInsp As Inspector
    Dim wdDoc As Object
    Dim oRng As Object
        On Error Resume Next
        Select Case Outlook.Application.ActiveWindow.Class
            Case olInspector
                Set olContact = ActiveInspector.currentItem
            Case olExplorer
                Set olContact = Application.ActiveExplorer.Selection.Item(1)
        End Select
        With olContact
            Set olInsp = .GetInspector
            Set wdDoc = olInsp.WordEditor
            Set oRng = wdDoc.Range
            'do something here with orng e.g. copy to the clipboard
            oRng.Copy
        End With
    lbl_Exit:
        Set olContact = Nothing
        Set olInsp = Nothing
        Set wdDoc = Nothing
        Set oRng = Nothing
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Regular
    Joined
    Feb 2022
    Posts
    9
    Location
    Thank you gmayor. Works great!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •