How to automatically update all fields in an Outlook message template (OFT)?

Status
Not open for further replies.

ngkatsaras

Member
Outlook version
Outlook 2010 64 bit
Email Account
Exchange Server
I created an Outlook message template file (OFT), there is a pre-formatted message where the message body contains a couple of field codes as follows:

Dear {FILLIN "Recipient's name"}:

blah blah blah

Kind regards,

{FILLIN "Sender's name"}

This works fine except that whenever I open the template, the fields do not automatically prompt me to update. For now I have instructed the users to do CTRL+A then F9 which will then prompt the user to input the data to be merged into the fields. But that is not as elegant as I would like.

I found out that in a Word template file you could do a macro as follows that will automatically prompt the user for input to define the field codes:

Sub AutoNew()
ActiveDocument.Fields.Update

End Sub

However, I don't seem to be able to get that to work with the OFT file.

I also tried naming the Sub AutoOpen() but that didn't work either.

Your assistance is greatly appreciated in advance.

Kind regards,

Nick K.
 
Re: How to automatically update all fields in an Outlook message template (OFT

Yes, Tools > References > checked Word 14.0 Office Library

So to clarify, what I'm trying to do is have this macro/VBA fire after the OFT creates the new message. I want it to pop up and prompt the user to input and update these field codes within the message body.

CTRL-A and then F9 does what I need, but I want that to happen automatically.

I found some other code that also seems to work in Word, but not in this OFT file:

Sub AutoNew()
Selection.WholeStory
Selection.Fields.Update

End Sub

I think the problem is that the macro needs to act upon the message body (object) portion and I don't know how to make that happen.
 
Re: How to automatically update all fields in an Outlook message template (OFT

I assume you have all of the following references set - (all but word should be set by default)

  • Visual Basic For Applications
  • Microsoft Outlook 14.0 Object Library
  • OLE Automation
  • Microsoft Office 14.0 Object Library
  • Microsoft Word 14.0 Object Library
It looks like you will need to get the Word.Document object from Outlook's Inspector.WordEditor object.

Sub AutoNew()

Dim objDoc As Word.Document

Dim objWord As Word.Application

Set objDoc = ActiveInspector.WordEditor

Set objWord = objDoc.Application

objWord.Selection.WholeStory

objWord.Selection.Fields.Update

End Sub

That works when i run it from the VBE.

Are you putting your macro in the template or in the VBE?
 
Re: How to automatically update all fields in an Outlook message template (OFT

Wow, thank you so much! The macro is now working in the Outlook message that is created by running the OFT file. The problem is that it doesn't run automatically. Is that possible?

What I want to do is distribute this OFT file to a bunch of users so they can just use it whenever they need it and I would like for it to automatically prompt to update the fields, if possible.

At this point at least, I can have them run the macro manually, but that's really not much easier than doing CTRL+A then F9. Maybe if there's some way I can include a button in the OFT that will run the macro, is that possible?

Thanks again!
 
Re: How to automatically update all fields in an Outlook message template (OFT

The users could put it on the ribbon, so its one click or keystroke, but auto-run would be better.

Is the macro in the oft or in Outlook's VB editor? It can be kicked off from the VB Editor with inspectors but i didn't have the code handy and needed to get an article written today. As soon as i get the article finished (whenever possible, I put it off all day long :)), i'll work on it.
 
Re: How to automatically update all fields in an Outlook message template (OFT

>Is the macro in the oft or in Outlook's VB editor?

The macro doesn't seem to be getting saved in the OFT. I have been running it from the VB editor.

I just opened the OFT on another computer and there was no sign of the macro.

Is there a way to include the macro in the OFT?

Thanks again for your help!

Nick
 
Re: How to automatically update all fields in an Outlook message template (OFT

Hello,

I am trying to do the very same thing, but I'm not completely following what you had to do to make it work. Can you share what you have in your macro please?

Thanks,

Jason
 
Hi, has anyone gotten an answer for this? I'm having the same issue. The macro doesn't seem to be attached to the outlook template.
 
Outlook doesn't run autonew macros. You can use a macro to open the template then run the macro.

How to Open Outlook Templates and Files using Toolbar Buttons

This is the first macro on that page merged with the code above:
Code:
Sub MakeItem()
Set newItem = Application.CreateItemFromTemplate("C:\Users\drcp\AppData\Roaming\Microsoft\Templates\test.oft")
newItem.Display


Dim objDoc As Word.Document
Dim objWord As Word.Application
Set objDoc = ActiveInspector.WordEditor

Set objWord = objDoc.Application

objWord.Selection.WholeStory
objWord.Selection.Fields.Update


Set newItem = Nothing

End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Cameron Piper Automatically update custom forms across multiple computers Outlook VBA and Custom Forms 1
Alex Hall When updating shared calendar, it does not automatically update personal calendar Using Outlook 3
S New Quick Step based on Team email QS - automatically update too Using Outlook 1
J update a meeting automatically? Using Outlook 1
A Why doesn't distribution lists update automatically Using Outlook 3
Q Sorting tasks by calculated field - automatically update task-fiel Outlook VBA and Custom Forms 9
M Outlook 365 macro - automatically attach file based on subject line Outlook VBA and Custom Forms 0
kburrows Outlook Automatically Merging Contacts Using Outlook 2
A Opening a link from an email automatically Outlook VBA and Custom Forms 0
A Opening a link from a specific sender automatically Outlook VBA and Custom Forms 4
X Run macro automatically when a mail appears in the sent folder Using Outlook 5
J Calendar events created on iPhone automatically changing default alert from 'None' to 'Time of Event' Using Outlook.com accounts in Outlook 0
Z Automatically adjust Outlook Reading Pane from bottom to right depending on portrait or landscape window Using Outlook 1
G Automatically delete email when a condition is met Outlook VBA and Custom Forms 1
Hornblower409 Automatically or Manually Backup Multiple Versions of VbaProject.OTM Outlook VBA and Custom Forms 1
B Outlook 2019 Automatically move email after assigning category Using Outlook 4
G automatically choosing "add to autocorrect" option Using Outlook 0
L Why are some email automatically going to "archive" Using Outlook 2
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
G Automatically delete messages in the synchronization folder Outlook VBA and Custom Forms 3
C Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 4
E Remove flag automatically Using Outlook 4
T Outlook 365 Move newly created tasks automatically on save. Outlook VBA and Custom Forms 1
M Outlook 365 Switching from AOL to Yahoo automatically Using Outlook 5
P Print attachments automatically and move the mail to an existing folder called "Ted" Outlook VBA and Custom Forms 4
B Zoom automatically next email item (VBA) Outlook VBA and Custom Forms 2
Paul Hobbs Automatically accept "Empty Folders" prompt Outlook VBA and Custom Forms 6
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
D Custom Search Folders not refreshing/updating automatically Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
P Automatically Categorize Meetings once they are accepted Outlook VBA and Custom Forms 5
W Automatically open attachments without automatically printing them Using Outlook 0
N How to set automatically the default or user defined Quickstyle Templates by Answer in Outlook Using Outlook 1
O Run macro automatically at sending an email Using Outlook 11
D Outlook 2016 automatically increment anniversaries Using Outlook 1
T Office 2013 no longer updating automatically Using Outlook 2
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
L Automatically Insert Recipient Name from To Field Outlook VBA and Custom Forms 33
N how to sync automatically when outlook opens Using Outlook 10
A Sort emails into subfolders based on sender and deleting emails automatically Outlook VBA and Custom Forms 3
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
C Need VBA code to automatically save message outside outlook and add date Outlook VBA and Custom Forms 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1

Similar threads

Back
Top