Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

Word VBA Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mike - 30 Nov 2004 23:23 GMT
Hi,

I am creating a Word document using VBA.  This document is a quote where I
am trying to add a signature based on the user.  Each user has an email
signature in Outlook, is there a way to pull this signature into Word?

Thanks
Ed - 01 Dec 2004 17:48 GMT
Mike:

If this VBA code is to be run on each user's machine, then the code at the
end of this post will open that user's RTF file containing their Outlook
signature and put it in a string.  If, however, you are going to create one
of these documents for any other user on your machine, you will need to get
a copy of their signature file and then add an Input Box (or other method)
of determining which user signature you need, and adjust the code
accordingly.

HTH
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
> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks
Ed - 01 Dec 2004 17:53 GMT
Mike - change the last block to
' Open file and get signature
Set doc1 = Documents.Open(strFile)
strSig = doc1.Content.Text
doc1.Close

MsgBox strSig

I forgot to close the sig file!

Ed

> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.