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 / June 2007

Tip: Looking for answers? Try searching our database.

Get document statistics - file info

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FotoArt - 02 Jun 2007 20:02 GMT
hello everyone

How do I access a file and get document stats such as FileName, Directory,
Template, Title, Created, LastSaved, LastSavedBy via a macro.
the files I want to excess are on a server.

Any help will be appreciated.
Jay Freedman - 02 Jun 2007 21:08 GMT
>hello everyone
>
[quoted text clipped - 3 lines]
>
>Any help will be appreciated.

See http://www.word.mvps.org/FAQs/MacrosVBA/DSOFile.htm.

Note that this works only for the Word 97-2003 file format and not for
the new Word 2007 format. If you need to deal with .docx/.docm format,
you'll need to open them as zip files and extract the appropriate bits
of XML. I don't know whether anyone has created a simple tool for that
yet.

--
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.
old man - 02 Jun 2007 21:48 GMT
Hi,

Here is a function that will do basically what you want...

Sub alldocs(whatdir)
Dim allinfo As String
Dim curdocinfo As String
Dim curver As Integer
Dim mytemplate As Template

Dim f1 As String

If Right(whatdir, 1) <> Application.PathSeparator Then
   whatdir = whatdir & Application.PathSeparator
End If

f1 = Dir(whatdir & "*.doc")
Do While f1 <> ""
    curdocinfo = ""
    Documents.Open FileName:=whatdir & f1
    curdocinfo = "Document - " & f1 & " is in folder - " & whatdir & vbCrLf
    curver = ActiveDocument.Versions.Count
    curdocinfo = curdocinfo & "Current Version Saved By - " &
ActiveDocument.Versions(curver).SavedBy & vbCrLf
    curdocinfo = curdocinfo & "Date Last Saved - " & FileDateTime(whatdir &
f1) & vbCrLf
    curdocinfo = curdocinfo & "Created By - " &
ActiveDocument.Versions(1).SavedBy & vbCrLf
   
    curdocinfo = curdocinfo & "Title - " &
ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) & vbCrLf
    curdocinfo = curdocinfo & "Template - " &
ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate) & vbCrLf & vbCrLf
    allinfo = allinfo & curdocinfo
    ActiveDocument.Close savechanges:=False
   
   f1 = Dir
Loop

Selection.HomeKey unit:=wdStory
Selection.InsertBefore allinfo

End Sub

invoke this with
alldocs("k:\dept25\alldocs")

Note:
you want to add error checking (on error...) and probably want to freeze the
screen while this is going on (lots of flashing as files are opened and
closed).
If a document was not saved as a version errors will be raised when this
code is run so add error checking...
This will check all the docs in the passed folder not subfolders of the
passed folder.

Old Man

> >hello everyone
> >
[quoted text clipped - 18 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
 
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.