[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2269
  • Last Modified:

How to access document properties via Dsofile from VBscript

Im need to access builtindocumentproperties for various documents; word, excel etc, and I need to use VBScript (not VBA or VB).

Does anyone know how to do this?

  • 2
1 Solution
First, you should download and run the DSOFILE component. If you haven't already, that could be done here:
This is a self-extracting ZIP file that contains a copy of DSOFILE.DLL as well as some sample code. Second, place a copy of the DLL in your Windows/System32 subdirectory, then run "regsvr32 dsofile.dll" to register it.
Next, create a virtual Web root and open a new ASP document in it. The code should be something like this:

<%@ Language=VBScript %>
<% option explicit %>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<table width="100%" border=1>
<TR><TH width="25%">Title</TH><TH width="10%">Size</TH>
<TH width="10%">Date</TH><TH width="*">Description</TH></TR>
    dim objPropReader         ' Property Reading object
    dim objFileProps          ' Object that stores the file
                              ' properties
    dim objFSO                ' File System Object
    dim objFile               ' File Object
    dim objFolder             ' Folder Object
    dim sMapPath              ' String to store the Real Path

    on error resume next    
    ' Create File System Object to get list of files
    set objFSO = createobject("Scripting.FileSystemObject")
    ' Set the Property Reader to get the file properties
    Set objPropReader = CreateObject("DSOLEFILE.PropertyReader")    
    ' Get the Windows NT path for the web page
    sMapPath = Server.MapPath(".")
    ' Set the folder object to the Mapped Path
    set objFolder = objFSO.GetFolder(sMapPath)
    ' For each file in the folder
    for each objFile in objFolder.files        
        ' Read the file properties so we have the Title and
        ' Description. In order to do this we need to use the
        ' .PATH which contains the path and the file name.
        ' .NAME only contains the file name.
        set objFileProps=
        if err.number = 0 then
             <TR><TD width="25%">
             <A HREF="<%=objFile.Name%>"><%
             ' Having used the name of the file in the HREF
             ' above, now we need to check to see if we have a
             ' title to use. If we don't have a title
             ' then we'll use the file name.
             if trim(objFileProps.Title) = "" then
                Response.Write objFile.Name
                Response.Write trim(objFileProps.Title)
             end if%></a></TD>
             <TD width="10%" align="Right">
             ' We'll format the file size so it looks pretty.
            if objFile.size < 1024 then
                Response.Write objFile.size & " Bytes"
            elseif objFile.size < 1048576 then
                Response.Write round(objFile.size/1024,1) & "KB"
                Response.Write round((objFile.size/1024)/1024,1)
                    & "MB"
            end if
             <TD><%=objFile.DateLastModified %></TD>
             <TD width="*">  <%=objFileProps.Comments%> </TD>
        end if

Read more here:
Dim fs,f
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.GetFile("c:\test.txt")
Response.Write("File created: " & f.DateCreated)
set f=nothing
set fs=nothing

Output: File created: 9/19/2001 10:01:19 AM

example from

works on all kinds of file type

Well, the question was about how to do 'properties via DSOFILE', not just FileSystemObject right?
John_E_LewisAuthor Commented:

   An excellent response.

   Also, worth looking at:


Also, not sure if its relevant but other examples use ""DSOleFile.PropertyReader" rather than "DSOLEFILE.PropertyReader"

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now