Autor Beitrag
ralph71
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Fr 11.11.16 13:32 
Hallo,

mittels
ausblenden C#-Quelltext
1:
2:
3:
var word = new Word.Application();
word.Visible = true;
word.Documents.Open("D:\\Visual\\Mein_Brief.dotx");

wird aktuell die Wordvorlage Mein_Brief.dotx geöffnet und mit weiter folgendem Code geändert.
Das führt aber nicht zum Ziel, weil die dotx geöffnet wird.

Wie kann eine neue Worddatei auf Basis der dotx erstellt werden?

Vielen Dank!

Grüße
RAlph

Moderiert von user profile iconTh69: C#-Tags hinzugefügt
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4764
Erhaltene Danke: 1052

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Fr 11.11.16 14:05 
Reicht nicht einfach
ausblenden C#-Quelltext
1:
document.SaveAs("file.docx");					

?

Evtl. hilft dir auch Create a Word Document From a Template using C#?
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4701
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Fr 11.11.16 14:14 
Laut Dokumentation hat Documents eine Add Methode der man das zu benutzende Template mitgeben kann.

msdn.microsoft.com/d...office/ff845011.aspx
ralph71 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Fr 11.11.16 16:44 
Hallo,

SaveAs reicht leider nicht, weil der Benutzer den Windows-Speicher-Dialog nicht bekommt.

Über die Add Methode bin ich schon gestolpert, habs aber nicht zum Fliegen gebracht. Muss ich nochmal schaun.

Danke euch.
Frühlingsrolle
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 12.11.16 13:00 
- Nachträglich durch die Entwickler-Ecke gelöscht -
ralph71 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Mo 14.11.16 08:36 
Hallo,
die Add Methode führte zum Ziel. Perfekt!

@Frühlingsrolle: Serienbrief --> das habe ich bereits realisiert und genau die von Dir angegebene Vorgehensweise umgesetzt.


Danke euch!