Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Modifier les propriété d’un document Microsoft Office: Exemple de word

Modifier,les,propriété,d'un,document,Microsoft,Office:,Exemple,de,word
{filelink=15058}

using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
using Word;
 
namespace office
{
  public class ModificationProprietesOffice
  {
    [STAThread]
    static void Main(string[] args)
    {
        object typeMissing = System.Reflection.Missing.Value;
      object BuiltInProps;
      Word._Document Doc;
      Word.ApplicationClass ExWord = new Word.ApplicationClass();
 
      ExWord.Visible = true;
      Doc = ExWord.Documents.Add(ref typeMissing, ref typeMissing, ref typeMissing, ref typeMissing);
      BuiltInProps = Doc.BuiltInDocumentProperties;
 
      Type TypeBuiltingProp = BuiltInProps.GetType();
      // Configurer la propriété 'Auteur' du document
      string Prop = "Author";
      string PropValue="sakoba";
      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();
    }
  }
 
}

No comments yet.

Leave a Comment