Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Storing add-in properties with workbook - how to? (VSTO 2007)
Hello Developers,
Where/how do I store Excel VSTO add-in properties with workbook? Is it possible? I would rather store some of my add-in properties somewhere within the workbook, rather than in registry or in a separate file since those properties are workbook specific. Thanks for any pointers. Thomas |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Storing add-in properties with workbook - how to? (VSTO 2007)
One place to keep properties is in named ranges. Global properties can go in
global range names while sheet specific properties can be store in local named ranges. They are easy to read from and write to. I know of at least one commercial application that uses this technique quite successfully. -- HTH... Jim Thomlinson "Thomas" wrote: Hello Developers, Where/how do I store Excel VSTO add-in properties with workbook? Is it possible? I would rather store some of my add-in properties somewhere within the workbook, rather than in registry or in a separate file since those properties are workbook specific. Thanks for any pointers. Thomas |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Storing add-in properties with workbook - how to? (VSTO 2007)
Hello Thomas,
We can store the add-in properties in Workbook.CustomDocumentProperties. Microsoft Office Excel 2003 and Microsoft Office Word 2003 provide built-in properties that are stored with workbooks and documents. In addition, you can create and modify custom document properties if there is additional information you want to store with the document. Use the CustomDocumentProperties property to work with custom properties. This property returns a DocumentProperties object, which is a collection of DocumentProperty objects. You can use the Item property of the collection to retrieve a particular property, either by name, or by index within the collection. The following example demonstrates how to add a custom property in Excel and assign it a value. -----------------VB.NET----------------------- Visual Basic Copy Code Sub TestProperties() Dim properties As Microsoft.Office.Core.DocumentProperties properties = CType(Me.CustomDocumentProperties, Office.DocumentProperties) If ReadDocumentProperty("Project Name") < Nothing Then properties("Project Name").Delete() End If properties.Add("Project Name", False, _ Microsoft.Office.Core.MsoDocProperties.msoProperty TypeString, _ "White Papers") End Sub Private Function ReadDocumentProperty(ByVal propertyName As String) As String Dim properties As Office.DocumentProperties properties = CType(Me.CustomDocumentProperties, Office.DocumentProperties) Dim prop As Office.DocumentProperty For Each prop In properties If prop.Name = propertyName Then Return prop.Value.ToString() End If Next Return Nothing End Function -----------------------C#------------------------------------------- C# Copy Code void TestProperties() { Microsoft.Office.Core.DocumentProperties properties; properties = (Office.DocumentProperties)this.CustomDocumentProp erties; if (ReadDocumentProperty("Project Name") != null) { properties["Project Name"].Delete(); } properties.Add("Project Name", false, Microsoft.Office.Core.MsoDocProperties.msoProperty TypeString, "White Papers", missing); } private string ReadDocumentProperty(string propertyName) { Office.DocumentProperties properties; properties = (Office.DocumentProperties)this.CustomDocumentProp erties; foreach (Office.DocumentProperty prop in properties) { if (prop.Name == propertyName) { return prop.Value.ToString(); } } return null; } You can get more information from the MSDN online documentations, http://msdn.microsoft.com/en-us/libr...75(VS.80).aspx Have a nice day! Best regards, Ji Zhou Microsoft Managed Newsgroup Support Team |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel 2007 - Workbook Properties - Company | Excel Discussion (Misc queries) | |||
Storing flag values at worksheet level (Property or Properties) | Excel Programming | |||
VSTO 2003 and 2007 Add-ins | Excel Programming | |||
Storing XML In Workbook | Excel Programming | |||
Storing workbook name | Excel Programming |