Document Properties in Excel are a set of data that describe the document.
This information includes the author, title, company name, and other information about the document (such as the file size or date of creation).
Document properties are also referred to as metadata.
Excel allows you to edit document properties that allow the users to get more information about the Excel files and also generates some of the document properties (such as file size or date) that help you sort and organize your files using Windows File Explorer.
In this tutorial, we will go through what document properties are.
In addition, we will show you how to edit some of the standard document properties of an Excel workbook.
We will then use these document properties in order to organize Excel files using Windows File Explorer.
Different Types of Document Properties in an Excel File
It’s helpful to understand the different types of document properties, in order to know more about what you can actually edit:
Standard Properties
Every Office document has a set of standard properties. These include the title, author, category, etc.
You can change these and enter your own text values for these property fields. Editing these fields can help you locate and identify your files when they are stored in folders.
Automatically Updated Properties
These are properties that the Office system auto-generates for you.
You cannot edit ‘Automatically Updated Properties’.
These properties include the size of your file, and the date when your file was created and/or modified. These are again useful in organizing your files based on size or date of creation.
I find this extremely useful when I want to quickly sort and get the files that were modified recently. This is made possible because this property value is automatically generated by the Office Application.
Custom Properties
These are additional properties, which a user can define for the Excel file. So if you need to add some information apart from what is already available in the standard and automatic properties, you can add Custom properties.
For example, if you’re working on a project, you may want to add a department property where you can specify what file contains the data of what department.
There are some pre-defined custom properties such as Department, Destination, or Date completed, and you can also create your own custom properties.
Excel allows you to choose whether you want to enter a text value, Date, Number, or Yes/No.
Document Library Properties
If you have created a document library and defined properties and rules for that library, then each file that you add should have those same properties. You will have to edit or correct the files if that is not the case.
In most cases, you only need to know about the Standard and Automatic document properties. I have rarely seen anyone work with Custom or Document Library Properties (in my personal experience)
Below are the steps to view all the document properties of a new blank Excel workbook.
- Create a new Blank workbook.
- Go to the File Tab, and select Info.
- You should see the Properties section, on the right-hand side.
- To see all the Properties, click the Show All Properties option.
- You should now see a complete list of all the properties associated with the workbook.
Note that since I created a new blank workbook and have not saved it yet, some of the properties are not yet available, such as the File size or the Last Modified date
How to Edit/Change the Standard Document Properties
As I mentioned earlier, Standard Document properties in Excel are editable and you can change them.
In this section, I will cover some of the common Standard document properties that you can change.
Changing the Title of the Workbook
To add a title to the workbook, do the following.
- Place the cursor in the Title textbox and enter the title of your choice. We will enter Sales Data.
Note: The title and the name of your workbook don’t have to be the same.
Adding a Tag to the Workbook
To add a tag to the workbook, do the following.
- Place the cursor in the Tags textbox and enter a tag that describes your workbook. We will enter Sales.
Adding Company Name to the Workbook
To add a Company name to the workbook, do the following.
- Place the cursor in the Company textbox and enter the name of your company or the company of interest. We will enter Company ABB.
Specify the Manager of the Document
If you need to specify the Manager, then do the following.
- In the Related People section, in the Manager textbox enter the name Al Wu.
Remove the Existing Manager/Author of the Workbook
To remove the existing Manager or Author of the workbook, do the following.
- Right-click the existing Manager entry.
- Select Remove Person.
- You should see the following.
Change the Name of the Author
The author is automatically added based on your username.
However, you can edit this or remove the author. If you would like to change the name of the author, do the following.
- Right-click the current author entry. Select Edit Property.
- Using the Edit person Dialog Box, change the name of the author. In this case, we will enter Jonathan Goodman and then click Ok.
- You should see the following.
How to See the Automatically Updated Properties
Save the workbook, and give it a name.
In this case, we named the workbook JuneSales.
We saved the file in a folder on our drive called CompanyData.
- Now go to the File Tab and select the Info option. You should see that Size, Last Modified, Created and Last Modified By have been updated automatically by the Office system.
In addition, you now have the option to open the file location.
- These fields will be updated by the Office system, every time you work on the workbook and save the workbook.
How to Set the Custom Properties in Excel
To set the Custom Properties of the workbook, do the following.
- Go to the File Tab and click on the Info option.
- Select the drop-down arrow next to Properties. Choose the Advanced Properties option.
- You should see the Properties dialog box.
- You can edit the standard Properties if you choose to from this Window as well. However, in this case, we will select the Custom Tab.
- Select Checked by. Under Type: choose Text and as the Value enter Lisa Ang.
- You should see the following after clicking the Add button.
- Click Ok.
Sort and Filter Your Files Using Document Properties
To sort Excel files using the Windows File Explorer, through document properties that we added, do the following.
- Go to the File Tab and choose Info. Click on the Open file location button.
- We see the following.
- We also see the standard sorting options which are Name, Date Modified, Type, and Size. We want to organize by Tags, since we have tagged all our Excel files in this folder with the appropriate tag.
- So, select the View tab and ensure in the Layout Group, that the Details Option is selected.
- Now click on the ‘Sort by’ drop-down arrow and select Choose Columns…
- You should see the following.
- Scroll down and check the Tags option.
- Click Ok.
- You should see that Tags have been added as a potential sorting option.
- By default, the sort is ascending, but if you click on Tags, it will change to descending order.
Now we want to filter and see only the workbooks that have been tagged with the Sales tag.
- Hover over the Tags option, to see the drop-down arrow.
- Click on the drop-down arrow to see the following options.
- Check the Sales option.
- Now the only files that should be shown in the folder are the ones that are tagged with the Sales tag. The drop-down arrow has also been replaced by a tick to show that there is a filter.
To remove the filter, do the following.
- Click on the tick, next to the Tags option.
- Uncheck Sales and you should see all the files in the folder.
Removing Document Properties
To remove the document properties from your Excel workbook, do the following.
- Go to the File Tab and select Info.
- Select ‘Check for Issues’ and then click on ‘Inspect Document’.
- You should see the Document Inspector Window. Click the Inspect button.
- You should see the following.
- So, to remove the Document Properties, click the Remove All button.
- You should see the following.
- Click Close.
Conclusion
In this tutorial, we have given you a comprehensive overview of how to view and edit document properties in Excel.
This is a useful skill to know if you want to organize and filter your files using Windows File Explorer.
If for some reason, you don’t want your Excel file to show any personal information such as the author, then you can also remove the document properties.
Other articles you may also like:
- How to Find out What Version of Excel You Have (Easy Way)
- How to Start Excel in Safe Mode
- How to Clear Cache in Excel?
- Why does Excel Open on Startup (and How to Stop it)
- How to Make Excel File Read Only
- How to Delete Hidden Rows or Columns in Excel?
- Why is Excel so Slow? 11 Tips to Fix Slow Excel Files!
- How to Mark an Excel Workbook as Final?
Keep everyone healthy; Get Vaccinated
Almost 50 years of programming experience. Click ‘+ More’ in my «Full Biography» to see links to some articles I’ve written.
Published: 2017-06-05
Browse All Articles > Custom Document Properties in Excel
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
under a Public Domain Work license
When developing Excel applications, it’s a common need to be able to store settings or non-sheet data so that they are available the next time you open Excel. Some examples of data you might want to store are a Yes/No value pertaining to the user seeing a certain message, a user-selected highlight color, or a count of how many times the user has opened the workbook.
There are several common ways to do that including ini files (text files with a recognized structure), regular text files, databases and the Registry, however some of those methods have potential problems with permissions or the processing time involved with opening and closing external files.
One less-known method that doesn’t have those problems is Custom Document Properties. These are Just like the built-in properties stored in Office documents (like those shown in the above picture) except that these are ones that you can create, modify or delete.
A Practical Example
I recently created an Excel application where I wanted to display an informational message when a certain action was performed but I realized that since the action would be performed many times that the message would soon become annoying. Because of that I needed to give the user a way to turn the message off or on as needed and to remember that choice the next time the workbook was opened, and I decided on a Custom Document Property.
The first step was to create the property and that was accomplished with this code.
Sub CreateCDP()
On Error GoTo CreateCDP_Error
With ActiveWorkbook.CustomDocumentProperties
.Add Name:="Show Message", _
LinkToContent:=False, _
Type:=msoPropertyTypeString, _
Value:="Yes"
End With
On Error GoTo 0
Exit Sub
CreateCDP_Error:
If Err.Number = -2147467259 Then
MsgBox "Custom DocumentProperty already exists"
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CreateCDP of Module Module1"
End If
End Sub
That created a property called «Show Message» with an initial value of «Yes». In other situations that value could could have been a number or other variable types. See this article for a complete description. The reason for the error checking is that an error will result if the property already exists.
To use the property I created a macro similar to this one.
Sub ShowAgain()
If ActiveWorkbook.CustomDocumentProperties("Show Message") = "Yes" Then
If vbCancel = MsgBox("Some long, possibly annoying, message." _
& vbCrLf & vbCrLf & "(Click 'Cancel' if you no longer wish to see this message)", vbOKCancel) Then
HideMessage
End If
End If
End Sub
That refers to the HideMessage macro which changes the value of the property to «No». It looks like the following.
Sub HideMessage()
With ActiveWorkbook.CustomDocumentProperties("Show Message")
.Value = "No"
End With
End Sub
I also created these two companion macros.
Sub ShowMessage()
With ActiveWorkbook.CustomDocumentProperties("Show Message")
.Value = "Yes"
End With
End Sub
Sub RemoveCDP()
On Error GoTo RemoveCDP_Error
With ActiveWorkbook.CustomDocumentProperties("Show Message")
.Delete
End With
On Error GoTo 0
Exit Sub
RemoveCDP_Error:
If Err.Number = 5 Then
MsgBox "Custom DocumentProperty does not exist"
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure RemoveCDP of Module Module1"
End If
End Sub
ShowMessage will turn the message on again, and RemoveCDP deletes the custom property. It has error checking because an error will occur if the property already exists.
I’ve attached this workbook which demonstrates the use of the custom property. All the code is in Module1.
CDP.xlsm
If you find that this article has been helpful, please click the “thumb’s up” button below. Doing so lets me know what is valuable for EE members and provides direction for future articles. It also provides me with positive feedback in the form of a few points. Thanks!
Almost 50 years of programming experience. Click ‘+ More’ in my «Full Biography» to see links to some articles I’ve written.
CustomProperty
Helps to create identifier with key, value format which helps developer to tag information within internal XML metadata of a Excel sheet. In this article we will see how we can create a custom property and retrieve a property. Use the Add method or the Item property of the CustomProperties collection to return a CustomProperty object.
After a CustomProperty object is returned, you can add metadata to worksheets by using the CustomProperties property of the Worksheet object with the Add method.
In this article we are using VSTO (Visual Studio Tools for office) in both flavors (C#, VB.Net) and VBA (Visual Basic for Applications) hence following prerequisites are recommended:
Prerequisites
- Visual Studio 2015 or above having Microsoft Office for Developer Tool installed
- Create Excel Addin in C# or VB code style (Visual Studio Tools for Office)
- Excel 2010 or above
- Create a ribbon designer and put button
C# code example
private void btnCustomProperty_Click(object sender, RibbonControlEventArgs e) { //Bind sheet reference excel.Worksheet oWorksheet = Globals.ThisAddIn.Application.ActiveSheet; //add property oWorksheet.CustomProperties.Add("Site_Name", "VBAOVERALL"); //Pull custom properties from sheet excel.CustomProperties oCustomProperties = oWorksheet.CustomProperties; //Iterate each property foreach (excel.CustomProperty oCustomProperty in oCustomProperties) { //Read property Console.WriteLine("Custom Property Name-" + oCustomProperty.Name); Console.WriteLine("Custom Property Value-" + oCustomProperty.Value); } }
VB.Net code example
Private Sub btnColorStop_Click(sender As Object, e As RibbonControlEventArgs) Handles btnColorStop.Click 'Bind sheet reference dim oWorksheet As excel.Worksheet oWorksheet = Globals.ThisAddIn.Application.ActiveSheet 'add property oWorksheet.CustomProperties.Add("Site_Name", "VBAOVERALL") 'Pull custom properties from sheet Dim oCustomProperties As excel.CustomProperties oCustomProperties = oWorksheet.CustomProperties 'Iterate each property For Each oCustomProperty As excel.CustomProperty In oCustomProperties 'Read property Console.WriteLine("Custom Property Name-" + oCustomProperty.Name) Console.WriteLine("Custom Property Value-" + oCustomProperty.Value) Next End Sub
VBA code example
Public Sub CreateCustomProperty() 'Bind sheet reference Dim oWorksheet As Worksheet Set oWorksheet = ActiveSheet 'add property oWorksheet.CustomProperties.Add "Site_Name", "VBAOVERALL" 'Pull custom properties from sheet Dim oCustomProperties As CustomProperties Set oCustomProperties = oWorksheet.CustomProperties 'Iterate each property Dim oCustomProperty As CustomProperty For Each oCustomProperty In oCustomProperties 'Read property Debug.Print "Custom Property Name-" & oCustomProperty.Name Debug.Print "Custom Property Value-" & oCustomProperty.Value Next End Sub
Output
Please leave your comments or queries under comment section also please do subscribe to out blogs to keep your self upto date.
Чтобы заполнить встроенные свойства (например, Тема, Руководитель, Организация, Автор, Категория, Ключевые слова, Название, Комментарий и т.д.) документа Excel, можно воспользоваться функцией FillWorkbookProperties:
(в её работе используется коллекция BuiltinDocumentProperties)
Sub ПримерИспользования_FillWorkbookProperties() FillWorkbookProperties ActiveWorkbook, "Название", "Тема", "Автор", "Ключевые Слова", , "EducatedFool", , "Компания" End Sub
Код функции FillWorkbookProperties:
Sub FillWorkbookProperties(ByRef wb As Workbook, _ Optional ByVal Title As String = vbNullString, Optional ByVal Subject As String = vbNullString, _ Optional ByVal Author As String = vbNullString, Optional ByVal Keywords As String = vbNullString, _ Optional ByVal Template As String = vbNullString, Optional ByVal LastAuthor As String = vbNullString, _ Optional ByVal Manager As String = vbNullString, Optional ByVal Company As String = vbNullString) On Error Resume Next MyComment = "http://excelvba.ru/" & vbNewLine & _ "Разработка макросов любой сложности " & "для Excel, Word, CorelDRAW" & vbNewLine With wb.BuiltinDocumentProperties If Len(Title) Then .Item(1) = Title If Len(Subject) Then .Item(2) = Subject If Len(Author) Then .Item(3) = Author If Len(Template) Then .Item(4) = Template .Item(5) = MyComment If Len(LastAuthor) Then .Item(7) = LastAuthor If Len(Manager) Then .Item(20) = Manager If Len(Company) Then .Item(21) = Company End With End Sub
Список индексов всех доступных свойств:
Название свойства | Назначение | |
1 | Title | Заголовок |
2 | Subject | Предмет |
3 | Author | Автор (создавший документ) |
4 | Keywords | Ключевые слова |
5 | Comments | Комментарии |
6 | Template | Шаблон документа |
7 | Last Author | Тот, кто последний сохранил документ |
8 | Revision Number | Число входов для редактирования |
9 | Application Name | Название приложения, обрабатывающего документ |
10 | Last Print Date | Дата и время последней печати |
11 | Creation Date | Дата создания |
12 | Last Save Time | Дата и время последнего сохранения |
13 | Total Editing Time | Общая продолжительность редактирования (минуты) |
14 | Number of Pages | Число страниц |
15 | Number of Words | Число слов |
16 | Number of Characters | Число символов |
17 | Security | Секретность |
18 | Category | Категория |
19 | Format | Формат |
20 | Manager | Менеджер |
21 | Company | Компания |
22 | Number of Bytes | Размер файла в байтах в момент последнего сохранения |
23 | Number of Lines | Число строк |
24 | Number of Paragraphs | Число абзацев |
25 | Number of Slides | Число слайдов (определено в PowerPoint, в остальных, вероятно, не используется) |
26 | Number of Notes | Число заметок к слайдам (определено в PowerPoint, в остальных, вероятно, не используется) |
27 | Number of Hidden Slides | Число скрытых слайдов (определено в PowerPoint, в остальных, вероятно, не используется) |
28 | Number of Multimedia Clips | Число клипов (определено в PowerPoint, в остальных, вероятно, не используется) |
29 | Hyperlink Base | База гиперссылок |
30 | Number of Characters (with spaces) | Общеечисло символов, включая пробелы |
- Remove From My Forums
-
Question
-
I have a need to store extra information about each cell in an Excel workbook. My plan would be to present this information and allow it to be editable via a custom RibbonBar tab.
I would want to allow a user within Excel to add this extra information to cells and then have this information be persisted when the workbook is saved normally. I’d want this information stored within the workbook, such that emailing the workbook to someone
else and them opening the workbook would allow them to see the extra data set on cells.I cannot find an elegant solution to this. An easy cop-out would be having a ‘Tag’ like property available on the range objects, but this does not exist.
I could abuse the comment tag on individual cells and store the data as serialised XML , but this just seems wrong.
Is there a better way of achieving this goal?
Thanks
Neil
Neil Kimber — Director of Technology, CPR
Answers
-
One way to do this is using CustomXMLParts (which I have only just discovered). You can create and access these whilst the workbook is open and they persist in the workbook (assuming its one of the 2007 or later file formats). You can even read/write them
from within a UDF. And they are fairly easy to debug because you can see the end result by unzipping the Excel XLSX file.You would need a 2-part XML structure where one part is the cell address and the second part is the data you want to store.
here is some test code
Option Explicit Public gPart As CustomXMLPart Sub create() Dim xPart As CustomXMLPart For Each xPart In ActiveWorkbook.CustomXMLParts If Not xPart.BuiltIn Then xPart.Delete Next xPart Set gPart = ActiveWorkbook.CustomXMLParts.Add("<fxlUDF> </fxlUDF>") End Sub Sub testxml() Dim xPart As CustomXMLPart Dim xNode As CustomXMLNode Dim xNodes As CustomXMLNodes Dim strxml As String Dim s1 As String Dim j As Long For Each xPart In ActiveWorkbook.CustomXMLParts If Not xPart.BuiltIn Then xPart.Delete Next xPart strxml = "<FxlRowMap>" & _ "<Pair> <k>123</k> <i>456</i> </Pair>" & _ "<Pair> <k>124</k> <i>999</i> </Pair>" & _ "</FxlRowMap>" Set xPart = ActiveWorkbook.CustomXMLParts.Add(strxml) Set xNode = xPart.SelectSingleNode("/FxlRowMap") xNode.AppendChildSubtree ("<Pair> <k>125</k> <i>1010</i> </Pair>") Set xNodes = xPart.SelectNodes("/FxlRowMap/Pair") For Each xNode In xNodes s1 = xNode.SelectSingleNode("k").Text Debug.Print s1 Debug.Print xNode.SelectSingleNode("i").Text Next xNode End Sub Function Funcxml(theRange As Range) Dim xNode As CustomXMLNode Set xNode = gPart.SelectSingleNode("/fxlUDF") xNode.AppendChildSubtree ("<Cell> <RC>" & Application.Caller.Address & "</RC> <V>" & theRange.Value & "</V> </Cell>") Funcxml = theRange End Function
Charles Excel MVP The Excel Calculation Site http://www.decisionmodels.com/
-
Marked as answer by
Sunday, April 29, 2012 12:36 PM
-
Marked as answer by