Solved

How update specific fields in Word when opening the file?

Posted on 2011-03-04
5
327 Views
Last Modified: 2012-05-11
Hello,

we use Word as default Outlook editor and we made some specific signatures for the people in htm format. My question is, how can I update some specific fields each time I click on new message in Outlook?

I've already a macro that gets info from a LDAP server and I just want that variables to be inserted/updated on a specific field in that signature file.

The final idea is to deploy that file to all my users and I don't have to modify the name, email address, title, etc as all the info is get from the AD.

Kindly Regards,
David
0
Comment
Question by:David_Pazos
  • 4
5 Comments
 

Author Comment

by:David_Pazos
ID: 35037800
Hi,

this is a sample of what I did. The signature file is in htm format, I've added inside 3 form fields named strName, strTitle and strEmail and I populate them when this macro is runned. The thing is, I can't run it automatically when I click new message in Outlook... any suggestions? :/

David
Sub AutoOpen()
'
    Dim objFSO

    Set objFSO = CreateObject("scripting.filesystemobject")

    Set objSysInfo = CreateObject("ADSystemInfo")
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" & strUser)

    strName = objUser.cn
    strTitle = objUser.Title
    strCompany = objUser.company
    strPhone = objUser.telephoneNumber
    strEmail = objUser.EmailAddress


   Dim FieldObj As Object

   Set FieldObj = ActiveDocument.FormFields("strName")
   FieldObj.Result = CStr(strName)
   Set FieldObj = ActiveDocument.FormFields("strTitle")
   FieldObj.Result = CStr(strTitle)
   Set FieldObj = ActiveDocument.FormFields("strEmail")
   FieldObj.Result = CStr(strEmail)
End Sub

Open in new window

0
 
LVL 15

Accepted Solution

by:
cquinn earned 500 total points
ID: 35041927
I suspect you may need to call your routine from the ThisOutlookSession Application_NewMail() event, rather than from the Word event
0
 

Author Comment

by:David_Pazos
ID: 35055078
Hi cquinn,

you're fantastic, you definitelly solved my problem )) I added the macro in the "ThisOutlookSession* calling the macro as you mentioned Application_NewMail() and it works!

Many many thanks!!! I've been stuck so long on this.
Have a great day
Kind Regards,
David
0
 

Author Comment

by:David_Pazos
ID: 35055098
oops.. finally, doesn't work totally as expected as it lunchs the macro as well if I get a new email and reports an error... :((( any ideas on how to fix this?
David
0
 

Author Comment

by:David_Pazos
ID: 35056709
ok just added that and that solved my problem ))
On Error GoTo 0
    Exit Sub

Open in new window

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you don't know how to downgrade, my instructions below should be helpful.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question