?
Solved

How update specific fields in Word when opening the file?

Posted on 2011-03-04
5
Medium Priority
?
332 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 2000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses

762 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