Solved

How update specific fields in Word when opening the file?

Posted on 2011-03-04
5
324 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok just added that and that solved my problem ))
On Error GoTo 0
    Exit Sub

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now