Diamonds_Mine said:
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.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.