Bonjour.
J'ai pas mal épluché le MSDN sans résultat... Je fais donc un dernier appel au secours...
Voilà, mon problème.
Dans un développement de type WIN (avec un Framework 1.1), un fichier Excel est utilisé.
Dans l'algorithme, il y a une vérification pour vérifier que le fichier est bien présent, puis il y a une vérification poru vérifier que le "contenu" du fichier est le bon.
Pour faire cela, on a décidé de "tagger" une propriété dans l'onglet "personnalisation" du fichier (option uniquement valable sur les produits de type OFFICE), une propriété qu'on appellera "Toto" dans laquelle je mets la valeur "12345".
Le programme devra vérifier cette propriété.
J'ai repéré le code pour récupérer les objets de type "Summary" (comme Author) comme dans l'exemple suivant (un peu à l'arrache selon moi dailleurs...)
Word.Application oWord;
Word._Document oDoc;
object oMissing = Missing.Value;
object oDocBuiltInProps;
object oDocCustomProps;
//Create an instance of Microsoft Word and make it visible.
oWord = new Word.Application();
oWord.Visible = true;
//Create a new Document and get the BuiltInDocumentProperties collection.
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing,
ref oMissing);
oDocBuiltInProps = oDoc.BuiltInDocumentProperties;
Type typeDocBuiltInProps = oDocBuiltInProps.GetType();
//Get the Author property and display it.
string strIndex = "Author";
string strValue;
object oDocAuthorProp = typeDocBuiltInProps.InvokeMember("Item",
BindingFlags.Default |
BindingFlags.GetProperty,
null,oDocBuiltInProps,
new object[] {strIndex} );
Type typeDocAuthorProp = oDocAuthorProp.GetType();
strValue = typeDocAuthorProp.InvokeMember("Value",
BindingFlags.Default |
BindingFlags.GetProperty,
null,oDocAuthorProp,
new object[] {} ).ToString();
MessageBox.Show( "The Author is: " + strValue,"Author" );
Mais je ne vois pas comment récupérer un attribut de l'onglet "personnalisation" (en anglais "Custom").
J'ai essayé de remplacer "Author" par "Toto", mais sans résultat.
J'ai beau fouiller dans l'aide MSDN, je ne vois rien...
Quelqu'un a t il déjà eu à faire face à ce problème ?
Merci pour votre aide.
****************************************************
Il n'y a pas de pb sans solutions : il faut juste trouver le temps pour les chercher