Hallo,
ich habe ein Word Dokument, wo ich diverse Felder in C# über eine GUI befülle. Das funktioniert alles schön und gut.
Jetzt möchte ich dass ich das bearbeitete Word Dokument drucke, was als PDF klappt, aber bei meinem Drucker zickt er herum und es kommt eine "Warnung"
Diese möchte ich aber automatisch bestätigen, damit der Druck startet, weil sonst kommt das Dokument nur in die Warteschleife vom Drucker und es wird nicht gedruckt.
public void ReplaceTextInWordDocument2(string filePath, string searchText, string replaceText, string searchDate, string replaceDate, int Seiten)
{
Word.Application wordApp = null;
Word.Document doc = null;
try
{
// 1. Word Anwendung starten
wordApp = new Word.Application();
wordApp.Visible = true;
// 2. Dokument öffnen
object file = filePath;
object nul = Type.Missing;
doc = wordApp.Documents.Open(ref file, ref nul, ref nul,
ref nul, ref nul, ref nul, ref nul, ref nul,
ref nul, ref nul, ref nul, ref nul, ref nul,
ref nul, ref nul, ref nul);
Statuslabel.Text = "Dokument wird geöffnet...";
// 3. Gesamten Inhalt auswählen
doc.Content.Select();
Statuslabel.Text = "Dokument wird gelesen...";
// 4. Suchen und Ersetzen für LOT Wert
Word.Find findObject = wordApp.Selection.Find;
findObject.ClearFormatting();
findObject.Text = searchText;
findObject.Replacement.ClearFormatting();
findObject.Replacement.Text = replaceText;
Statuslabel.Text = "LOT wird gesucht...";
// Replace-Parameter richtig setzen für LOT Wert
findObject.Execute(
FindText: searchText,
ReplaceWith: "LOT " + replaceText,
Replace: Word.WdReplace.wdReplaceAll);
Statuslabel.Text = "LOT wird gesucht und Ersetzt...";
//ReplaceDatum
Word.Find findDate = wordApp.Selection.Find;
findDate.ClearFormatting();
findDate.Text = searchDate;
findDate.Replacement.ClearFormatting();
findDate.Replacement.Text = replaceDate;
Statuslabel.Text = "Datum wird gesucht...";
// Replace-Parameter richtig setzen
findDate.Execute(
FindText: searchDate,
ReplaceWith: replaceDate,
Replace: Word.WdReplace.wdReplaceAll);
Statuslabel.Text = "Datum wird gesucht und Ersetzt...";
// 5. Dokument speichern und schließen
doc.PrintOut(20, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Seiten); //Seiten ist die Anzahl wie viele gedruckt wird
Statuslabel.Text = "Es wird gedruckt...";
object saveChanges = Word.WdSaveOptions.wdSaveChanges;
doc.SaveAs2("Print.docx", ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul, ref nul);
doc.Close(SaveChanges: Word.WdSaveOptions.wdDoNotSaveChanges);
wordApp.Quit(saveChanges, ref nul, ref nul);
//doc.Close(ref saveChanges, ref nul, ref nul);
//wordApp.Quit(ref saveChanges, ref nul, ref nul);
//MessageBox.Show("Erledigt");
Statuslabel.Text = "Fertig";
}
Wie kann ich diese Meldung unterdrücken bestätigen, damit der Druck startet?
Bin da eher ein Laie in C#