Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 12-22-2015, 01:54 AM
gmayor's Avatar
gmayor gmayor is offline Auto-update field codes in Outlook Template - AutoOpen Macro not working Windows 10 Auto-update field codes in Outlook Template - AutoOpen Macro not working Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

What you are trying to achieve is not possible. Outlook templates do not store macros and while the Outlook editor is Word based it is only superficially like Word. If it was for your own use, you could add a macro to Outlook to enter or change the date in the message body, but you couldn't transport it with the template for other users.

If that will suffice then the following macro in your ThisOutlookSession folder will update and fix the date field (if present) when you click 'Send' for all messages.
Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olInsp As Inspector
Dim wdDoc As Object
Dim orng As Object
Dim ofld As Object
    With Item
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set orng = wdDoc.Range
        For Each ofld In orng.Fields
            If ofld.Type = 31 Then
                ofld.Update
                ofld.Unlink
            End If
        Next ofld
        .Display
        .Save
    End With
lbl_Exit
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 

Tags
auto update, macro, outlook template



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA script to update field codes? Calab Word VBA 1 04-07-2014 09:27 PM
Auto Update Fields Macro kveldulv Outlook 0 06-07-2013 02:30 PM
Auto-update field codes in Outlook Template - AutoOpen Macro not working Macro to update ole links not working kisa500 PowerPoint 7 02-05-2013 03:52 AM
Auto-update field codes in Outlook Template - AutoOpen Macro not working Auto update Filename field Oliver Beirne Word VBA 4 10-19-2012 03:33 AM
Table of Contents - Direct Field Implementation - Auto-Update Numbering ztag Word 3 01-19-2012 03:04 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:36 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft