By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,030 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Import file properties from MS Word to Access

P: n/a
I have a large set of Word documents that I wish to catalogue in an
Access database. Each document has a set of file properties populated
(title, subject, author, keywords, comments ect), so I'd like to import
those into an Access table for processing. I've written VBS macros in
the past to import data from Excel sheets into Access tables, but the
same functionality does not appear to be available for Word. Any clues
or sample code appreciated.

Thanks

Apr 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
a.*******@steel-sci.com wrote:
I have a large set of Word documents that I wish to catalogue in an
Access database. Each document has a set of file properties populated
(title, subject, author, keywords, comments ect), so I'd like to import
those into an Access table for processing. I've written VBS macros in
the past to import data from Excel sheets into Access tables, but the
same functionality does not appear to be available for Word. Any clues
or sample code appreciated.


Perhaps one way is to use Automation (VBA Tools > References - Check the
Microsoft Word X Object Library [X = your version of Word]) to get the
Document.CustomDocumentProperties or the Document.BuiltInDocumentProperties.

There's probably an API that can scan folder contents for the same info
(in Windows XP if the cursor hovers over a Word file in Windows Explorer
the BuiltIn properties information appears).
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Apr 21 '06 #2

P: n/a
Thanks for that. However, I ended up doing it the other way around.
That is, using Word to export the file properties to Access. Sample
code below:

Sub GetDataToDataBase()

' The following is the code that you would use to transfer the file
properities from Word into an Access database:

'Define variables

Dim vConnection As New ADODB.Connection
Dim vRecordSet As New ADODB.Recordset

'provide connection string for data using Jet Provider for Access
database
vConnection.ConnectionString = "data source=mydatabase.mdb;
Provider=Microsoft.Jet.OLEDB.4.0;"

'Open a new version of the temporary RecordSet accessing the table in
Database
vRecordSet.Open "MyTable", vConnection, adOpenKeyset,
adLockOptimistic

'we can't enter "nothing", so only set variables with some data entered
info the Field
If ActiveDocument.BuiltInDocumentProperties("Title") <> "" Then
vRecordSet!Title =
ActiveDocument.BuiltInDocumentProperties("Title")
End If

' repeat for "Subject", "Keywords", "Comments", "Creation Date",
"Last Save Time", "Category",
' "Author""Manager", "Company" as desired
'update the RecordSet to the database, this adds the information to the
table in the database.
vRecordSet.Update
'close the recordset
vRecordSet.Close
'close objects
vConnection.Close
'clear object to free up memory
Set vRecordSet = Nothing
Set vConnection = Nothing

End Sub

Apr 27 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.