Word et CSharp

De Banane Atomic
Aller à la navigationAller à la recherche

Exemples

Insérer un zip sous forme d’icône

Csharp.svg
object missing = Missing.Value;

var wordApp = new ApplicationClass();
Document doc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);

object start = 0;
Range rng = doc.Range(ref start, ref missing); // début du document

object zipFilePath = @"chemin\MonArchive.zip";
object classType = "Package";
// chemin vers la dll contenant l'icône
object iconFileName = @"C:\Windows\System32\zipfldr.dll";
object oIconLabel = "texte";
object oTrue = true;
object oFalse = false;
rng.InlineShapes.AddOLEObject(ref classType, ref zipFilePath,
    ref oFalse, ref oTrue, ref iconFileName, ref missing, 
    ref oIconLabel, ref missing);

object docFilePath = @"chemin\MonDocument.doc";
doc.SaveAs(ref docfilename, ref missing, ..., ref missing);
doc.Close(ref missing, ref missing, ref missing);
wordApp.Quit(ref missing, ref missing, ref missing);