Autor Beitrag
Y_Pedro
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Di 27.04.10 13:29 
Hallo,

ich brauche dringend Eure Unterstützung !!???
ich würde gerne einen Autotext zu einen bestimmten Word Datei einfügen, und dabei den Inhalt des Dokumentes aktualissieren.
habe schon versucht aber klappt nicht so ganz.
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
            object fileName = @"C:\tmp\Test.docx";
            object missing   = System.Reflection.Missing.Value;
            String text         = "AutoText";
            String textValue = "AutoTextValue";

     Microsoft.Office.Interop.Word.ApplicationClass oWordApp = new                 
                                           Microsoft.Office.Interop.Word.ApplicationClass();
            
     Microsoft.Office.Interop.Word.Document oWordDoc = 
                                           oWordApp.Documents.Open(ref fileName,
                          ref missing, ref missing, ref missing, ref missing, ref missing,
                          ref missing, ref missing, ref missing, ref missing, ref missing,
                          ref missing, ref missing, ref missing, ref missing, ref missing);

     oWordDoc.Activate();
     Template oTpl = (Template)oWordDoc.get_AttachedTemplate();

//ab Hier klappt es nicht
            oTpl.AutoTextEntries.Add(text , textValue );

     oWordApp.Application.Quit(ref missing, ref missing, ref missing);

Vielen Dank

Moderiert von user profile iconKha: B- durch C#-Tags ersetzt
Moderiert von user profile iconKha: Topic aus C# - Die Sprache verschoben am Di 27.04.2010 um 13:47