Setting Metadata in Word and Accessing It From Excel

richh

Board Regular
Joined
Jun 24, 2007
Messages
245
Office Version
  1. 365
  2. 2016
I posted this question on Stack Overflow today, with no results


My question is - How can I set extended properties in a Word Document (not so easy) and read them via the shell in Excel (easy enough) OR set custom properties in Word (easy enough) and read them from Excel (not so easy).

I'm trying to write a program that updates a Word document's metadata with content control boxes. The Excel document then loops through a directory that holds these documents and catalogs them by the metadata. In Word, I can set built-in properties in the DocumentBeforeSave sub via...
VBA Code:
Application.ActiveDocument.BuiltInDocumentProperties("Keywords").Value = _
Application.ActiveDocument.SelectContentControlsByTitle("Tags").Item(1).Range.Text

and retrieve those in Excel via the shell...
VBA Code:
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(WB.Path & "\QA\")

For Each strFileName In objFolder.Items
inputStr = objFolder.GetDetailsOf(strFileName, 18) 'Tags
'...
'...

next strFileName

The problem is that there are indexes in the "GetDetailsOf" function that I want to use but can't figure out how to set in Word. For example, I'd like to set the Division (GetDetailsOf index 155), Group (172), Program (277), and Attachments (219) fields. How do you set properties such as these that are not built-in?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,214,885
Messages
6,122,090
Members
449,065
Latest member
Danger_SF

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top