Solved

Reading Office 2007 document Properties from Access 2007 code without opening the document (e.g. Word 2007).

Posted on 2009-03-30
9
594 Views
Last Modified: 2013-11-27
I want to read the Properties (Author, Title, Subject etc.) of Office documents such as Word 2007, Excel 2007 and PowerPoint 2007 without opening them, from VBA code in Access 2007. Is this possible and if so, how? For the sake of discussion, it would probably be best to take the case of reading document properties for a Word 2007 file (call it: "TestDoc.xlsx" located in a folder "C:\TestFolder"). I appreciate any help on this. Thanks.
0
Comment
Question by:DataTrain
  • 5
  • 4
9 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24022459
Hello DataTrain,

The following post shows how to use the DSO OLE Document Properties Reader 2.0 library to get at document
properties without actually opening them:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_22022458.html#17720721

It will require downloading a DLL from here: http://support.microsoft.com/?id=224351

Warning: while this works with Office 2003 and earlier, I have not tested it using the new OpenXML file types
from Office 2007...

Regards,

Patrick
0
 

Author Comment

by:DataTrain
ID: 24027148
Hi. I downloaded the DLL and then added it using Tools menu, References and ticked "DSO OLE Document Properties Reader 2.1" However, it fails at the first line...
"Dim fso As Scripting.FileSystemObject"
with Compile error: User-defined type not defined. Was this code designed for Access 2007?
Note also that I my objective is to copy the Property data into an Access table fields.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24027866
DataTrain,

Sorry!  Add a reference to the Microsoft Scripting Runtime library; that is the source for the FileSystemObject
class and its related classes.

Regards,

Patrick
0
 

Author Comment

by:DataTrain
ID: 24028131
That helps a bit but I now I get Run-time error 3192, could not find output table 'FileStuff".
Any explanation you can give about how this is supposed to work would be helpful as I am unfamiliar with some of your code. Thanks.
0
[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24028451
DataTrain,

Please post the code you have so far.

Regards,

Patrick
0
 

Author Comment

by:DataTrain
ID: 24028657
I was just using your code...
Sub FileStuff()
 

    Dim fso As Scripting.FileSystemObject

    Dim fld As Scripting.Folder

    Dim fil As Scripting.File

    Dim dsofil As DSOFile.OleDocumentProperties

    

    Set fso = New Scripting.FileSystemObject

    Set fld = fso.GetFolder("C:\Folder\folder\subfolder")

    Set dsofil = New DSOFile.OleDocumentProperties

    

    DoCmd.SetWarnings False

    

    For Each fil In fld.Files

        dsofil.Open fil.Path, True, dsoOptionDefault

        DoCmd.RunSQL "INSERT INTO FileStuff (FileName, Folder, Size, Created, Modified, Title, " & _

            "Subject, Author) Values ('" & fil.Name & "', '" & fil.ParentFolder.Path & "', " & _

            fil.Size & ", #" & fil.DateCreated & "#, #" & fil.DateLastModified & "#, '" & _

            dsofil.SummaryProperties.Title & "', '" & dsofil.SummaryProperties.Subject & "', '" & _

            dsofil.SummaryProperties.Author & "')"

        dsofil.Close

    Next

    

    DoCmd.SetWarnings True

    

    Set dsofil = Nothing

    Set fil = Nothing

    Set fld = Nothing

    Set fso = Nothing

    

End Sub

Open in new window

0
 

Author Comment

by:DataTrain
ID: 24028698
The only difference was that I cahnged:
Set fld = fso.GetFolder("C:\Folder\folder\subfolder")
to
Set fld = fso.GetFolder("C:\Test")
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 250 total points
ID: 24029539
DataTrain,

The example I posted assumed that there is a table in the database, FileStuff, with columns for FileName,
Folder, Size, Created, Modified, Title, Subject, and Author.

Are you looking to store file information in a table?  If so, what is the name of that table, and what are the
columns?

Regards,

Patrick
0
 

Author Closing Comment

by:DataTrain
ID: 31564500
I appreciate your help - thank you.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I. Introduction In a previous article (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_6537-PaperPort-Upgrade-How-to-download-and-install-updated-versions-of-PaperPort-11-and-12.html) (now deprecated), I discussed how to upgrad…
PaperPort 14.5 Patch 1 update is often not detected or downloaded automatically. This article provides direct download links to solve the problem for retail (non-bundled) versions of the Standard and Professional editions, as well as the Professiona…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
This video Micro Tutorial is the first in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles al…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now