Get Outlook signature through Word VBA: what objects, properties?

E

Ed

I do a fair amount of VBA in Word and Excel, but never before in Outlook!
I'm trying to activate the Outlook application through Word VBA so I can
access the email signature. I've set a reference to the Outlook library,
and I set an object to New Outlook.Application. But after Googling and
searching through the library and Help, I still can't get a handle on how to
get the signature. Can someone help me with the objects and properties I
should be looking at?

Thank you.
Ed
 
E

Ed

Never mind. I found some other posts (thank you, Eric Legault!) explaining
where the signature is stored. After that, it was relatively easy to grab
it. I post the following code from Word VBA for anyone else interested.

Ed

Sub Foo_Sig()

Dim strName As String
Dim strFile As String
Dim strFile2 As String
Dim strSig As String
Dim doc1 As Document

' Get UserName
strName = Environ$("Username")
' Name of folder containing sig files
strFile2 = "C:\Documents and Settings\" & _
strName & "\Application Data\Microsoft\Signatures"

' Get rtf sig file
With Application.FileSearch
.LookIn = strFile2
.FileName = "*.rtf"
.Execute

strFile = .FoundFiles(1)
End With

' Name of rtf sig file
strFile2 = "C:\Documents and Settings\" & _
strName & "\Application Data\Microsoft\Signatures\*.rtf"

' Open file and get signature
Set doc1 = Documents.Open(strFile)
strSig = doc1.Content.Text

MsgBox strSig

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top