More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 23-Aug-2017 19:37

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 ]  
 Code Essentials Printer Friendly Version
Beginner’s section on how to work in the VBA environment, how to work with functions and expressions – generally not specific to Outlook
Topic
Open Standard Outlook Templates
I open every Morning a Series of Outlook Templates in the following directory.
C:\Users\cowins\AppData\Roaming\Microsoft\Templates\

The List of Templates is as Follows
Doxford Webhosting backup report - xxxxxx.oft
Doxford servers XXXXXX.oft
Duty Admin (Group 1) - XXXXXX.oft
Duty Admin (Group 2) - XXXXXX.oft
UKS - MDAD Webhosting backup report - xxxxxx.oft
XXXXXX Transmission 6157 EDS Doxford - DFADUX0003.oft

Ive created a macro (tried to from examples on the web) and added a customised button to open but just doesn't work. Obviously its my lack of VBA knowledge.
What exactly is wanted is macro just to open all those Templates. Ideal would be one that also Renames the Subject with some text and Today's date. ANy help would be much appreciated

Example of code so far that doesnt work (I did have a myfolder definition but couldnt get working)

Sub OpenCustomTemplate()

  'Open template from a macro button

  'added to the ribbon.

  Set myItem = Items.Open("Templates.Doxford Webhosting backup report - xxxxxx")
  myItem.Display
  Set myItem = myFolder.Items.Add("Doxford Webhosting backup report - xxxxxx.oft")
  myItem.Display
  Set myItem = myFolder.Items.Add("Doxford servers XXXXXX.oft")
  myItem.Display
  Set myItem = myFolder.Items.Add("Duty Admin (Group 1) - XXXXXX.oft")
  myItem.Display
  Set myItem = myFolder.Items.Add("Duty Admin (Group 2) - XXXXXX.oft")
  myItem.Display
  Set myItem = myFolder.Items.Add("UKS - MDAD Webhosting backup report - xxxxxx.oft")
  myItem.Display
  Set myItem = myFolder.Items.Add("XXXXXX Transmission 6157 EDS Doxford - DFADUX0003.oft")
  myItem.Display
  
End Sub




  

  09-May-2013  03:24
  09-May-2013  16:42   
See here http://msdn.microsoft.com/en-us/library/aa220081(v=office.11).aspx

Sub CreateFromTemplate()
    Dim myOlApp As Outlook.Application
    Dim MyItem As Outlook.MailItem
    Set myOlApp = CreateObject("Outlook.Application")
    Set MyItem = myOlApp.CreateItemFromTemplate("C:\statusrep.oft")
    
    MyItem.Subject = "Some text " & Date
    
    MyItem.Display
End Sub

 
    Page [ 1 ]