473,378 Members | 1,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Custom Document Properties

I'm developing a database to create a hyperlinked index of files in a folder. I'm trying to get document properties for all files in a folder. Properties like FileName, Author, and Tags. Using VBA how can I grab document property information from each file and store it in a table. The documents are Word documents.
Thanks
Jun 21 '17 #1
2 2107
ADezii
8,834 Expert 8TB
You can grab Built-In or Custom Properties of a Word Document by accessing the BuiltInDocumentProperties and/or CustomDocumentProperties of a Word Document Object. Typical Built-In Properties would be:
Expand|Select|Wrap|Line Numbers
  1. 01            Title
  2. 02            Subject
  3. 03            Author
  4. 04            Keywords
  5. 05            Comments
  6. 06            Template
  7. 07            Last author
  8. 08            Revision number
  9. 09            Application name
  10. 10            Last print date
  11. 11            Creation date
  12. 12            Last save time
  13. 13            Total editing time
  14. 14            Number of pages
  15. 15            Number of words
  16. 16            Number of characters
  17. 17            Security
  18. 18            Category
  19. 19            Format
  20. 20            Manager
  21. 21            Company
  22. 22            Number of bytes
  23. 23            Number of lines
  24. 24            Number of paragraphs
  25. 25            Number of slides
  26. 26            Number of notes
  27. 27            Number of hidden Slides
  28. 28            Number of multimedia clips
  29. 29            Hyperlink base
  30. 30            Number of characters (with spaces)
  31. 31            Content type
  32. 32            Content status
  33. 33            Language
  34. 34            Document version
Jun 21 '17 #2
PhilOfWalton
1,430 Expert 1GB
Interesting question, but this might get you started

These first 2 routines get the names of all .doc & .docx in a named folder and all subfolders.

In this case my main folder is called "E:\Phil Data\Word Documents\BOATS\"
Note the final "\"

Expand|Select|Wrap|Line Numbers
  1. Function GetWordFiles(HostFolder As String)
  2. '?GetWordFiles("E:\Phil Data\Word Documents\BOATS\")
  3.     ' Routine to get all files & foldere in host folder
  4.  
  5.     Dim FileSystem As Object
  6.  
  7.     Set FileSystem = CreateObject("Scripting.FileSystemObject")
  8.     DoFolder FileSystem.GetFolder(HostFolder)
  9.  
  10. End Function
  11.  
  12. Sub DoFolder(Folder)
  13.  
  14.     Dim SubFolder As Variant
  15.     Dim File As Variant
  16.  
  17.     For Each SubFolder In Folder.SubFolders
  18.         DoFolder SubFolder
  19.     Next
  20.  
  21.     For Each File In Folder.Files
  22.         If right(File.Name, 5) = ".docx" Or right(File.Name, 4) = ".doc" Then   ' For whaterver files you need
  23.             Debug.Print File.Name
  24.             fEnumProps Folder & "\" & File.Name
  25.             Debug.Print "*******************************************************"
  26.             Debug.Print
  27.         End If
  28.     Next
  29.  
  30. End Sub
  31.  
The next bit of code displays about 25 lines of the document's properties. Obviously you must select the ones you want and load them to your table.

Expand|Select|Wrap|Line Numbers
  1. Function fEnumProps(strInFile As String)
  2.  
  3.     Dim objWord As Object, objDocProps As Object
  4.     Dim i As Integer
  5.  
  6.     On Error Resume Next
  7.  
  8.     Set objWord = CreateObject("Word.Application")
  9.  
  10.     With objWord
  11.         .Documents.Open strInFile
  12.         Set objDocProps = objWord.ActiveDocument.BuiltInDocumentProperties
  13.  
  14.         For i = 0 To objDocProps.Count - 1
  15.             Debug.Print objDocProps(i).Name, objDocProps(i).Value
  16.         Next i
  17.     End With
  18.  
  19.     objWord.Application.Quit savechanges:=False
  20.     Set objWord = Nothing
  21.  
  22. End Function
  23.  
Phil
Jun 21 '17 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: CJ | last post by:
Hi In my PHP script I'm able to update bookmarks without in hassles but document properties just don't work! I know in VB custom properties can be changed with the following: ...
3
by: StrongBad | last post by:
Does anyone know of a way to access the document properties of an office document using ASP? I need to be able to read things like the Title, Author, and Comments fields and pull that information...
1
by: Sandeep | last post by:
Hi, I am trying for word 2000 automation with c#. There I want to get all custom document property of the document as follows: Microsoft.Office.Core.DocumentProperties props =...
2
by: Shacker | last post by:
Hi, I've written a custom control that has 6 labels and 3 properties. The properties are of type ENUM so they show up as a drop list when the control is dropped on a form. I choose a value for...
1
by: chambersdon | last post by:
How do I get the public properties of my custom control to show in the designer. The properties are all Strings but they do not show up in the designer property window. My custom control...
2
by: Suresh Reddy | last post by:
Hi, Please help me in resolving the problem with Custom Document Prporties. I have developed one Dll to print the word documents in VB5 by using AutoTexe Entries. Created the component and...
2
by: Nathan Sokalski | last post by:
I have a custom control with properties named MinValue, MaxValue, and Value (all of which I have assigned a DefaultValue design-time attribute). The Value property must be between (or equal to) the...
0
by: Alan T | last post by:
I have modified custom properties of a Word document by code. And there are fields in this Word document link to the properties, however, after running the application and reopen the document, the...
0
by: Support | last post by:
Hello: Apparently we can read and write to Document Properties using Dsofile.dll (seel http://support.microsoft.com/?id=224351) My question is: can this be extended to non-native Microsoft...
0
by: hannahhhh1056 | last post by:
Hello! I´m trying to create a makro that finds the text in a wddocument formatted as "heading 1" and then puts it in the document properties. I know how to get the text into doc properties but i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.