Share via


insert document ID Value in excel

Question

Monday, February 20, 2012 8:07 PM

I'm creating document templates at the moment for office use, and was easily able to do this in Word, but excel is a whole other story. How woudl i go about inserting the Document ID value into a cell in excel? i see it in the document properties, but it obviously isn't a part of the BuiltinDocumentProperties class, does anyone konw how to go about this? i'm hoping it's similart to the answer found here: http://social.technet.microsoft.com/Forums/en-US/sharepointadmin/thread/78fe92fc-70d2-4631-a48b-4f80df2363ed

All replies (1)

Wednesday, February 22, 2012 9:31 AM âś…Answered

Hi,

We do not need to create an additional column on SharePoint library. I only show Document ID column in the library.

Open the Excel file on the SharePoint site in Excel application. Click File > Options > Customize Ribbon, and ensure 'developer" is selected. Click OK. Now save the file as a Macro Enabled Excel Workbook. From the developer ribbon, click on 'View Code'. Right click on Microsoft Excel Objects and click on Insert > Module. Paste the user defined function below into the module:

Function DocID()  Dim wb As Workbook  Set wb = ThisWorkbook  For Each prop In wb.ContentTypeProperties    If prop.Name = "Document ID Value" Then      DocID= prop.Value    End If  Next propEnd Function

Now return to the Excel sheet and enter the function =DocID() in any of the Excel cells to display the Document ID.

Best Regards,

Sally Tang