The code I posted was VBA code, not formula code. You need to create a
User Defined Function in VBA. Press ALT F11 to open the VBA Editor
(VBE). There, press CTRL R to display the Project Explorer window if
it is not already visible (typically on the left side of the screen).
Find your project workbook in the Project Explorer, select it, then go
to the Insert menu and choose Module. This will create a code module
named Module1 in your workbook's VBA Project. In that module, enter
the following code:
Function GetProp(PropName As String, _
Optional Reference As Excel.Range) As Variant
On Error GoTo ErrH:
Dim DocProps As Office.DocumentProperties
Dim WB As Excel.Workbook
If Reference Is Nothing Then
Set WB = ThisWorkbook
Else
Set WB = Reference.Parent.Parent
End If
Set DocProps = _
WB.BuiltinDocumentProperties
GetProp = CStr(DocProps(PropName).Value)
Exit Function
ErrH:
GetProp = CVErr(xlErrValue)
End Function
Now, close the VBE.
Back in Excel, you can call this function from a cell with a function
like
=GetProp("Author")
Change "Author" to the name of the property whose value you want to
return. If the property doesn't exist or isn't set, the function
returns a #VALUE error. If Reference is not specified, the property is
read from the workbook that contains the code. To look up a property
in another (open) workbook, pass a reference to that workbook as the
Reference. For example, to get the Author property of Book3.xls, use
=GetProp("Author",[Book3.xls]Sheet1!A1)
It doesn't matter what reference you pass to GetProp as long as it
refers to a cell in the workbook whose properties you want to
retrieve.
Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)