Condividi:        

scelta della stampante tramite codice

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

scelta della stampante tramite codice

Postdi trittico69 » 23/01/12 18:04

È possibile modificare questo codice, che è abbinato a un tasto “stampa” e far si che quando clicco su “stampa” mi faccia scegliere le stampanti collegate al mio pc che sono

1) "Olivetti d-Copia 2500MF KX su Ne00:"

2)"Lexmark Optra E310 (MS) su LPT1:"

e il codice è


Codice: Seleziona tutto
Dim rng, cl, INIZIALE, RIGAINIZIALE, NRIGAFINALE, RIGAFINALE, RV, rr, ROWFINALE

Sub Oval1_Click() 'stampa automaticamente tutti i nominativi in ordine alfabetico pronti per essere attaccati sulla rubrica
'
On Error Resume Next
'
Sheets("archivio").Select
Range("A3:D1312").Select
Selection.Copy
Sheets("stampa rubrica").Select
Range("A1").Select
ActiveSheet.Paste Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'
Range("A1:D10000").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Key2:=Range("B1") _
        , Order2:=xlAscending, Header:=xlNo, OrderCustom:=1, MatchCase:=False, _
        Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
        xlSortNormal
Range("A1").Select
'
If Range("A1").Value = "." Then
Set rng = Sheets("stampa rubrica").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
rr = 0
RIGAINIZIALE = Range("A2").Address
Rows("1:1").Select
Selection.EntireRow.Hidden = True
Else
Set rng = Sheets("stampa rubrica").Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
rr = 0
RIGAINIZIALE = Range("A1").Address
End If
'
For i = 65 To 90
INIZIALE = Chr(i)
'
For Each cl In rng
If cl <> "" And Left(cl, 1) = INIZIALE Then
cl.Select
rr = rr + 1
riga = ActiveCell.Address
Row = ActiveCell.Row
End If
Next
'
Range("A" & Row).Offset(1, 0).Select
RIGAFINALE = Selection.Address
ROWFINALE = Selection.Row
'
RV = Range("G6").Value - (rr Mod Range("G6").Value)
If RV = Range("G6").Value Then RV = 0
Range("A" & Row + 1 & ":E" & Row + RV).Select
Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
'
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .Weight = xlThin
    End With
'
Range(RIGAINIZIALE & ":E" & Row + RV).Select
Selection.PrintOut
'
Range(RIGAFINALE & ":E" & ROWFINALE + RV - 1).Select
Selection.Delete shift:=xlUp
'
Range(RIGAFINALE).Select
'
If Selection.Value <> "" Then
Set rng = Sheets("stampa rubrica").Range("A" & Selection.Row & ":A" & Range("A" & Rows.Count).End(xlUp).Row)
rr = 0
RIGAINIZIALE = RIGAFINALE
Else
Exit For
End If
'
Next
'
Rows("1:1").EntireRow.Hidden = False
MsgBox "Stampa ultimata"
'
Exit Sub
'
End Sub
trittico69
Utente Senior
 
Post: 497
Iscritto il: 16/08/09 18:41

Sponsor
 

Re: scelta della stampante tramite codice

Postdi Flash30005 » 23/01/12 19:04

Inserisci una userform con Pulsanti opzione all'interno di una Cornice
Assegnerai a seconda della scelta una o l'altra stampante
che ne vba potrebbe essere così
Codice: Seleziona tutto
If OptionButton1 = True then
PrintDf = "Olivetti d-Copia 2500MF KX"
else
PrintDf = ")"Lexmark Optra E310 (MS)"
Endif
Prts = Shell("RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " & PrintDf)


Ciao
Flash
Win10 + Office 2010 Ita
"Fotografica" al servizio dell'immagine
Avatar utente
Flash30005
Moderatore
 
Post: 8517
Iscritto il: 27/09/07 11:44
Località: Roma +o-

Re: scelta della stampante tramite codice

Postdi trittico69 » 23/01/12 21:03

ok grazie
trittico69
Utente Senior
 
Post: 497
Iscritto il: 16/08/09 18:41

Re: scelta della stampante tramite codice

Postdi Anthony47 » 24/01/12 01:07

In alternativa puoi inserire nella tua macro questo codice che ti fara' scegliere la stampante tra quelle installate:
Codice: Seleziona tutto
'scegli printer
SelPrint = Application.Dialogs(xlDialogPrinterSetup).Show
If SelPrint = False Then
    MsgBox "Stampa Cancellata"
    Exit Sub   'Se Annulla, termina la macro; o altra operazione
End If

Ciao
Avatar utente
Anthony47
Moderatore
 
Post: 19196
Iscritto il: 21/03/06 16:03
Località: Ivrea


Torna a Applicazioni Office Windows


Topic correlati a "scelta della stampante tramite codice":


Chi c’è in linea

Visitano il forum: Nessuno e 98 ospiti