14 August 2009
09:17:58
sergey
Posts: 0
|
C# app: Reading and modifying MS Office document meta data
bytes.com/topic/c-sharp/answers/757466-c-app-reading-modifying-ms-office-document-meta-data
- object GetWordDocumentPropertyValue(Word.Document document, string propertyName)
- {
- object builtInProperties = document.BuiltInDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- object propertyValue = propertyType.InvokeMember("Value", BindingFlags.GetProperty, null, property, new object[] { });
- return propertyValue;
- }
-
- object GetExcelWorkbookPropertyValue(Excel.Workbook workbook, string propertyName)
- {
- object builtInProperties = workbook.BuiltinDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- object propertyValue = propertyType.InvokeMember("Value", BindingFlags.GetProperty, null, property, new object[] { });
- return propertyValue;
- }
-
- object GetPowerPointPresentationPropertyValue(PowerPoint.Presentation presentation, string propertyName)
- {
- object builtInProperties = presentation.BuiltInDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- object propertyValue = propertyType.InvokeMember("Value", BindingFlags.GetProperty, null, property, new object[] { });
- return propertyValue;
- }
-
- void SetWordDocumentPropertyValue(Word.Document document, string propertyName, string propertyValue)
- {
- object builtInProperties = document.BuiltInDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- propertyType.InvokeMember("Value", BindingFlags.SetProperty, null, property, new object[] { propertyValue });
- document.UpdateSummaryProperties();
- document.Save();
- }
-
- void SetExcelWorkbookPropertyValue(Excel.Workbook workbook, string propertyName, string propertyValue)
- {
- object builtInProperties = workbook.BuiltinDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- propertyType.InvokeMember("Value", BindingFlags.SetProperty, null, property, new object[] { propertyValue });
- workbook.Save();
- }
-
- void SetPowerPointPresentationPropertyValue(PowerPoint.Presentation presentation, string propertyName, string propertyValue)
- {
- object builtInProperties = presentation.BuiltInDocumentProperties;
- Type builtInPropertiesType = builtInProperties.GetType();
- object property = builtInPropertiesType.InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, builtInProperties, new object[] { propertyName });
- Type propertyType = property.GetType();
- propertyType.InvokeMember("Value", BindingFlags.SetProperty, null, property, new object[] { propertyValue });
- presentation.Save();
- }
|
21 August 2009
11:31:31
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
Understanding the Word Object Model from a .NET Developer's Perspective
msdn.microsoft.com/en-us/library/aa192495(office.11).aspx
|
21 August 2009
12:05:03
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
2007 Microsoft Office System Update: Redistributable Primary Interop Assemblies
www.microsoft.com/downloads/details.aspx
|
21 August 2009
12:07:35
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
|
21 August 2009
12:23:29
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
|
27 August 2009
11:22:24
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
www.java2s.com/Code/CSharp/Office/ModifyWordDocumentProperties.htm
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
using Word;
namespace Client.Chapter_19___Office_Integration
{
public class ModifyDocumentProperties
{
[STAThread]
static void Main(string[] args)
{
object Missing = Missing.Value;
object BuiltInProps;
object CustomProps;
Word._Document Doc;
Word.ApplicationClass MyWord = new Word.ApplicationClass();
MyWord.Visible = true;
Doc = MyWord.Documents.Add(ref Missing, ref Missing, ref Missing, ref Missing);
BuiltInProps = Doc.BuiltInDocumentProperties;
Type TypeBuiltingProp = BuiltInProps.GetType();
//Setting abuilt-in property
string Prop = "Author";
string PropValue;
object AuthorProp = TypeBuiltingProp.InvokeMember("item", BindingFlags.Default | BindingFlags.GetProperty, null, BuiltInProps, new Object[] { Prop });
Type TypeAuthorProp = AuthorProp.GetType();
PropValue = TypeAuthorProp.InvokeMember("Value", BindingFlags.Default | BindingFlags.GetProperty, null, AuthorProp, new Object[]{}).ToString();
System.Windows.Forms.Application.Run();
}
}
}
|
27 August 2009
11:56:39
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
Considerations for server-side Automation of Office
support.microsoft.com/default.aspx
|
27 August 2009
12:22:46
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
|
27 August 2009
12:31:24
sergey
Posts: 0
|
Re: C# app: Reading and modifying MS Office document meta data
Microsoft Developer Support OLE File Property Reader 2.1 Sample (KB 224351)
www.microsoft.com/downloads/details.aspx
|