Log in

View Full Version : [SOLVED:] Copying Contact Notes with formatting



dma
02-21-2022, 05:52 AM
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.

gmayor
02-21-2022, 06:16 AM
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

dma
02-21-2022, 06:31 AM
Thank you gmayor. Works great!