Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - Workbook Properties - Company JMay Excel Discussion (Misc queries) 2 January 19th 09 02:34 PM
Storing flag values at worksheet level (Property or Properties) bstobart Excel Programming 5 September 12th 07 07:00 AM
VSTO 2003 and 2007 Add-ins Aale de Winkel Excel Programming 0 June 29th 07 08:54 AM
Storing XML In Workbook Ray Price[_3_] Excel Programming 2 January 22nd 07 10:55 AM
Storing workbook name jnasr00[_7_] Excel Programming 2 January 18th 06 09:06 AM


All times are GMT +1. The time now is 12:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"