user default template directory

  • Thread starter Thread starter Rick B
  • Start date Start date
R

Rick B

I have a basic macro in Outlook which opens a specific form I developed. The
code is:

Sub OpenWeeklyReport()
Dim myOlApp As Application
Dim myItem As Object

Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItemFromTemplate _
("C:\Templates\Weekly Report.oft")
myItem.Display

End Sub

Is there a way to dynamically set the myItem file path to the users default
template directory so the code does not have to be modified for each user
that wants to use this macro?

Thank you in advance,

-rick
 
What default template folder? There is no default Outlook OFT template
folder that I know of. You could use almost any folder you wanted.
 
I'm referring to the template directory listed for Office applications from
Word's User Templates in Tools|Options|File Locations area. This can be
different from user to user but I was hoping there would be a way to
dynamically reference this directory.

-rick
 
Oh, Word templates. Well, there is a default location for those that you can
use but that varies depending on the version of Word. And the user can
change the default anyway, so it may not be valid. And the location for Word
templates is not a default location for Outlook form templates anyway.

You can use Windows Scripting to get the current Windows profile name and
put that in a string that puts together a path to the default folder. Or you
can post a question in one of the Word programming groups and see if there's
a way of querying Word to see if it can return the current template folder.
Of course the next time your code runs the user might have changed it and
you wouldn't be able to find your templates...
 
Back
Top