Προς το περιεχόμενο

Βοήθεια στην VB ή VBA


Ν._Βοναπάρτης

Προτεινόμενες αναρτήσεις

Χρειάζομαι ένα module ή script, σε VB ή VBA, ώστε να μπορώ να αλλάξω τον printer μεταξύ δυο εκτυπώσεων μέσα από ACCESS 2000.

Π.χ Το report A να φύγει στον εκτυπωτή HP4050 ενώ το αμέσως επόμενο report B να φύγει στον εκτυπωτή HP2200 inkjet.

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

Γραμμένο σε ~10' οπότε σίγουρα γίνεται πολύ καλύτερα (έλεγχοι για null objects, πχ μη ορισμένος default printer κλπ) αλλά πάντως δίνει μια πρώτη κατεύθυνση...

είναι vba module

-------------------------------------------------

Option Compare Database<p>Sub xPrintReports()

Dim iDevPrintCount As Integer 'for number of printers present, zero based

Dim iRepCount As Integer 'for number of reports in db, zero based

Dim defPrinter As Printer 'declare a printer object

Dim iCtr As Integer 'a counter

iCtr = 0

iDevPrintCount = Printers.Count 'count the printers present

Set defPrinter = Application.Printer 'store the current default printer to restore at end

If iDevPrintCount >= 2 Then 'if at least 2 printers exist

iRepCount = Application.CurrentProject.AllReports.Count 'count the reports

If iRepCount >= 1 Then 'if at least 1 report exists

For i = 1 To iRepCount

If iCtr = 1 Then 'set it so that the value alternates between

iCtr = 0 '0 êáé 1 se kathe loop

Else

iCtr = 1

End If

'------

' anoixe to report se preview kane default ton ena printer

' ektypose..

' kai kleise to report

' to idio gia epomeno me allo printer

DoCmd.OpenReport CStr(Application.CurrentProject.AllReports.Item(i - 1).Name), acViewPreview

Set Application.Printer = Application.Printers.Item(iCtr) 'set the first printer as default

DoCmd.PrintOut acPrintAll, , , acDraft

DoCmd.Close acReport, CStr(Application.CurrentProject.AllReports.Item(i - 1).Name), acSaveNo

Next

End If

End If

Set Application.Printer = defPrinter 'epanefere ton arxiko default printer

End Sub

-------------------------------------------------

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

  • 1 μήνα μετά...

Φίλε BuFu

Σε ευχαριστώ- έστω και καθυστερημένα- για το module που μου έστειλες.

Η εντολή: Dim defPrinter As Printer όμως δεν μπορεί να αναγνωριστεί από την Access 2000, που έχω.

Σε ευχαριστώ και πάλι για την προσπάθειά και βοήθειά σου.<p>[ 29-01-2002: Το μήνυμα επεξεργάστηκε από: Ν. Βοναπάρτης ]</p>

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...