Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2006

Tip: Looking for answers? Try searching our database.

When A Template Was Last Accessed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Diamonds_Mine - 06 Oct 2006 14:13 GMT
Good morning,

Using Word 2003 -- Is there a way to determine when all the templates in a
folder were last used/accessed using vba?  Thank you for any help you can
provide.
Jay Freedman - 06 Oct 2006 15:29 GMT
> Good morning,
>
> Using Word 2003 -- Is there a way to determine when all the templates
> in a folder were last used/accessed using vba?  Thank you for any
> help you can provide.

I'm not sure why you'd want to do this in VBA. The Date Accessed column in
Windows Explorer can show you the same information more easily (if you don't
have it displayed, click View > Choose Details and select it). To answer the
question, though...

You can use the FileSystemObject in the Scripting Runtime to get any file's
Last Accessed Date. As near as I can tell, for a template that does show the
last time the template was used to create a new document, but I don't know
whether that's actually documented somewhere.

In the VBA editor, go to Tools > References and put a checkmark next to
"Microsoft Scripting Runtime". Then paste in this sample macro:

Sub TemplateAccessDates()
   Dim fs As FileSystemObject
   Dim fldr As Folder
   Dim tmpl As File

   Set fs = CreateObject("Scripting.FileSystemObject")
   If Not fs Is Nothing Then
       Set fldr =
fs.GetFolder(Options.DefaultFilePath(wdUserTemplatesPath))
       For Each tmpl In fldr.Files
           If (LCase(Right(tmpl.Name, 4)) = ".dot") And _
              (Left(tmpl.Name, 1) <> "~") Then
               MsgBox tmpl.Name & " accessed " & tmpl.DateLastAccessed
           End If
       Next
   End If
End Sub

If you want to know about templates in a folder other than the User
Templates location, replace the
"Options.DefaultFilePath(wdUserTemplatesPath)" with a string containing the
path to that folder.

Signature

Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.