Laden...

word drucken - argumente von PrintOut !?!

Erstellt von romu2000 vor 15 Jahren Letzter Beitrag vor 15 Jahren 3.057 Views
R
romu2000 Themenstarter:in
291 Beiträge seit 2006
vor 15 Jahren
word drucken - argumente von PrintOut !?!

Hallo zusammen,

ich möchte mit folgendem Code ein worddokument drucken welches mit Textmarken gefüllt wird:


string dokpfadangabe;
            dokpfadangabe = documentDataGridView.CurrentRow.Cells[2].Value.ToString();
            
            Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
            app.Visible = true;
            

            //Dokument erstellen
            object template = dokpfadangabe;
            object optional = Missing.Value;

            object visible = true;

            Microsoft.Office.Interop.Word.Document doc = app.Documents.Add(ref template,
                ref optional,
                ref optional,
                ref visible);
            

            //Textmarke füllen
            object marke1 = "Faxnummer";
            object marke2 = "Kundennummer";
            object marke3 = "Titel";
            object marke4 = "Anrede";
            object marke5 = "Nachname";
            object marke6 = "Vertreter";

            //test
           

            

            // testende
            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke1);
            app.Selection.TypeText(telefaxTextBox.Text);

            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke2);
            app.Selection.TypeText(kdnrTextBox1.Text);

            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke3);
            app.Selection.TypeText(titelComboBox.Text);

            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke4);
            app.Selection.TypeText(anredeComboBox.Text);

            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke5);
            app.Selection.TypeText(nachnameTextBox.Text);

            app.Selection.GoTo(ref optional, ref optional, ref optional, ref marke6);
            app.Selection.TypeText(VTuserTextBox.Text);
            
            

            app.ActivePrinter = "Tobit Faxware";
            app.PrintOut(ref template,ref optional,ref visible, ref marke1, ref marke2, ref marke3, ref marke4, ref marke5, ref marke6);


Ich bekomme es aber absolut nicht mit den Argumenten vom PrintOut hin.

Wieviele müssen denn dort eigentlich rein ???

Viele Grüße

Ronny

230 Beiträge seit 2007
vor 15 Jahren

Wieviele müssen denn dort eigentlich rein ???

Hi! 18, wenn ich mich nicht verzählt habe 🙂 Einfach diese Forumsdatenbank mit "PrintOut" füttern und alle Deine Fragen werden automatisch beantwortet 🙂 - sarabande

R
romu2000 Themenstarter:in
291 Beiträge seit 2006
vor 15 Jahren

Hi,

habe mir jetzt fast alle Threads zu "printout" durchgelesen , aber bezgl. der Argumente fürs printout bin ich keinen Meter weiter gekommen.

Könnte sich evtl. jemand erbarmen und mir kurz erläutern wie sich die Argumente zusammensetzen ??? 😉

EDIT:

habs jetzt so hinbekommen, weiss aber auch nicht warum das so ist:


app.PrintOut(ref optional, ref optional, ref optional, ref optional, ref optional, ref optional,ref optional, ref optional, ref optional, ref optional,ref optional, ref optional, ref optional, ref optional,ref optional, ref optional, ref optional, ref optional, ref optional);

allerdings ist so die exception weg, word startet mir dasd dokument aber nicht mehr richtig sondern friert ein.

Grüße & Danke im voraus

ronny

738 Beiträge seit 2007
vor 15 Jahren

die Doku kann dir die bedeutung der Parameter wohl am besten erklären:

http://msdn.microsoft.com/de-de/library/microsoft.office.tools.word.document.printout(VS.80).aspx

R
romu2000 Themenstarter:in
291 Beiträge seit 2006
vor 15 Jahren

hey super,

ich wollte das ganze jetzt anhand eines beispiels aus dem Forum nochmals amchen.-

Habe den Code so eingegeben wie er hier funktioniert hat. Ich erhalte allerdings die Fehlermeldung:

Es wurde versucht, im geschützten Speicher zu lesen ...

An was liegt denn das Bitte. Mein Speicher istd efinitiv nicht defekt. !!!

Hier der Code.


{
string dokpfadangabe;
            dokpfadangabe = documentDataGridView.CurrentRow.Cells[2].Value.ToString();
            Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.ApplicationClass();
            word.Visible = true;
            object missing = Missing.Value;
            object saveChanges = false;


            // Öffne Word-Vorlage
            object template = dokpfadangabe;
            word.Documents.Add(ref template, ref missing, ref missing, ref missing);

            // Fülle Daten in Textmarke ein
            object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
            object name = "Kundennummer";
            word.Selection.GoTo(ref what, ref missing, ref missing, ref name);
            word.Selection.TypeText(kdnrTextBox1.Text);

            word.Application.PrintOut(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, ref missing, ref missing, ref missing,
                ref missing);
}

Die Textmarke wird richtig gesetzt, das Dokument ist geöffnet und beim letzten "{" wirft mir mein Programm die exception.

Hoffe mir kann geholfen werden 😉

Viele Grüße

Ronny

R
romu2000 Themenstarter:in
291 Beiträge seit 2006
vor 15 Jahren
erledigt

Habs jetzt hinbekommen 🙂

INTELLISENSE ist mein KÖNIG 🙂

Danke