Solved

How update specific fields in Word when opening the file?

Posted on 2011-03-04
5
330 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
Mailbox Overload?
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:
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

717 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