von Angelwings » Fr, 03.12.2010 11:32
Hallo Leute

,
ich weiß diese Thema ist schon breit getreten und ich hab mir wirklich Mühe gegeben und rumgebastelt und gesucht .... nur die Lösung hab ich nicht gefunden -.-
also das Problem ist das ich mittels einem Makro eine Vorlage fülle.
Nach dem füllen soll ggf. ein Druckerdialog aufgerufen werden oder einfach gedruckt.
So ein weiteres Problem ist, das ein Drucker schon vorgegeben ist.
Ich hoff ihr versteht das Problem.
Ich geb mal gleich meinen Code dazu das ihr es vlt. versteht ^^.
Code: Alles auswählen
dim TempPath as string 'ist ein Pfad zm Tempverzeichnis
dim VorlageDoc as object 'Ist das bearbeitete Dokument
Private Sub datei_drucken(repro As Boolean)
Dim drucken
Dim Druckerdialog
Dim alterDrucker
Dim neuerDrucker As String
Dim anz
if repro then
drucken = Val(myGetProfile("ReproPrint", "Drucken", TempPath$ + "\PBS.INI"))
If Akt_pbs = 1 then
Druckerdialog = Val(myGetProfile("ReproPrint", "DruckerDialog", TempPath$ + "\PBS.INI"))
else
Druckerdialog = 0
end if
neuerDrucker = myGetProfile("ReproPrint", "ReproPrint", TempPath$ + "\PBS.INI")
' Wieviele Exemplare sollen gedruckt werden ?
anz = Val(myGetProfile("ReproPrint", "Exemplare", TempPath$ + "\PBS.INI"))
else
drucken = Val(myGetProfile("WinWord", "Drucken", TempPath$ + "\PBS.INI"))
If Akt_pbs = 1 then
Druckerdialog = Val(myGetProfile("WinWord", "DruckerDialog", TempPath$ + "\PBS.INI"))
else
Druckerdialog = 0
end if
neuerDrucker = myGetProfile("WinWord", "Drucker", TempPath$ + "\PBS.INI")
' Wieviele Exemplare sollen gedruckt werden ?
anz = Val(myGetProfile("WinWord", "Exemplare", TempPath$ + "\PBS.INI"))
end If
If drucken = 1 Then
' Wenn Wert nicht gesetzt mind. 1 Exemplar
If anz < 1 Then
anz = 1
End If
On Error GoTo -1: On Error GoTo printbye
Dim document As object
dim dispatcher as object
document = VorlageDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
'Options.PrintBackground = False
If Druckerdialog = 1 Then
If neuerDrucker <> "" Then
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Printer"
args1(0).Value = neuerDrucker
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1())
else
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args())
End If
Else
If neuerDrucker <> "" Then
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Printer"
args2(0).Value = neuerDrucker
args2(1).Name = "Copies"
args2(1).Value = anz
args2(2).Name = "Collate"
args2(2).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args2())
else
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Copies"
args3(0).Value = anz
args3(1).Name = "Collate"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args3())
End If
End If
'If IsDocumentDirty() = -1 Then FileSave
'On Error GoTo -1: On Error GoTo 0
End If
GoTo printbyebye
printbye:
' Jedes erzeugte Dokument schließen
' ActiveDocument.Close
printbyebye:
End Sub
So das Problem ist jetzt das der Druckerdialog nicht angezeigt wird oder das der einfach druckt.
Und machnmal wenn der Dialog angezeigt wird eben nicht den neuen Drucker anzeigt.
Helft mir bitte

Hallo Leute :) ,
ich weiß diese Thema ist schon breit getreten und ich hab mir wirklich Mühe gegeben und rumgebastelt und gesucht .... nur die Lösung hab ich nicht gefunden -.-
also das Problem ist das ich mittels einem Makro eine Vorlage fülle.
Nach dem füllen soll ggf. ein Druckerdialog aufgerufen werden oder einfach gedruckt.
So ein weiteres Problem ist, das ein Drucker schon vorgegeben ist.
Ich hoff ihr versteht das Problem.
Ich geb mal gleich meinen Code dazu das ihr es vlt. versteht ^^.
[code]
dim TempPath as string 'ist ein Pfad zm Tempverzeichnis
dim VorlageDoc as object 'Ist das bearbeitete Dokument
Private Sub datei_drucken(repro As Boolean)
Dim drucken
Dim Druckerdialog
Dim alterDrucker
Dim neuerDrucker As String
Dim anz
if repro then
drucken = Val(myGetProfile("ReproPrint", "Drucken", TempPath$ + "\PBS.INI"))
If Akt_pbs = 1 then
Druckerdialog = Val(myGetProfile("ReproPrint", "DruckerDialog", TempPath$ + "\PBS.INI"))
else
Druckerdialog = 0
end if
neuerDrucker = myGetProfile("ReproPrint", "ReproPrint", TempPath$ + "\PBS.INI")
' Wieviele Exemplare sollen gedruckt werden ?
anz = Val(myGetProfile("ReproPrint", "Exemplare", TempPath$ + "\PBS.INI"))
else
drucken = Val(myGetProfile("WinWord", "Drucken", TempPath$ + "\PBS.INI"))
If Akt_pbs = 1 then
Druckerdialog = Val(myGetProfile("WinWord", "DruckerDialog", TempPath$ + "\PBS.INI"))
else
Druckerdialog = 0
end if
neuerDrucker = myGetProfile("WinWord", "Drucker", TempPath$ + "\PBS.INI")
' Wieviele Exemplare sollen gedruckt werden ?
anz = Val(myGetProfile("WinWord", "Exemplare", TempPath$ + "\PBS.INI"))
end If
If drucken = 1 Then
' Wenn Wert nicht gesetzt mind. 1 Exemplar
If anz < 1 Then
anz = 1
End If
On Error GoTo -1: On Error GoTo printbye
Dim document As object
dim dispatcher as object
document = VorlageDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
'Options.PrintBackground = False
If Druckerdialog = 1 Then
If neuerDrucker <> "" Then
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Printer"
args1(0).Value = neuerDrucker
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args1())
else
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args())
End If
Else
If neuerDrucker <> "" Then
dim args2(2) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Printer"
args2(0).Value = neuerDrucker
args2(1).Name = "Copies"
args2(1).Value = anz
args2(2).Name = "Collate"
args2(2).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args2())
else
dim args3(1) as new com.sun.star.beans.PropertyValue
args3(0).Name = "Copies"
args3(0).Value = anz
args3(1).Name = "Collate"
args3(1).Value = false
dispatcher.executeDispatch(document, ".uno:Print", "", 0, args3())
End If
End If
'If IsDocumentDirty() = -1 Then FileSave
'On Error GoTo -1: On Error GoTo 0
End If
GoTo printbyebye
printbye:
' Jedes erzeugte Dokument schließen
' ActiveDocument.Close
printbyebye:
End Sub
[/code]
So das Problem ist jetzt das der Druckerdialog nicht angezeigt wird oder das der einfach druckt.
Und machnmal wenn der Dialog angezeigt wird eben nicht den neuen Drucker anzeigt.
Helft mir bitte :(