Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

stampa PDF

Ultimo Aggiornamento: 28/10/2016 09:46
Post: 180
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
22/02/2015 08:28

Salve questa macro per stampa PDF mi ha sempre funzionato:


Sub stampa_PDF()

  Dim sDefPrinter As String, avviso As String
  
    
avviso = MsgBox("hai filtrato le righe per PDF?", vbInformation + vbYesNo + vbDefaultButton2, "AVVISO")
 If avviso = 7 Then
 Exit Sub
 
 End If
 
  sDefPrinter = Application.ActivePrinter
  Application.ActivePrinter = "PDFCreator su Ne00:"
  ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
      "PDFCreator su Ne00:", Collate:=True
  Application.ActivePrinter = sDefPrinter
  
End Sub



ora mi dà errore:

errore run time 1004
metodo acriveprinter dell'oggetto application non riuscito

qui

Application.ActivePrinter = "PDFCreator su Ne00:"


pdfcreator naturalmente è installato e se lo faccio da excel > stampa funziona tutto.
Un aiuto?
patrik
------------------
excel 2003 / 20007
Post: 180
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
22/02/2015 08:42

Forse l'errore è qui:

sDefPrinter = Application.ActivePrinter
Application.ActivePrinter = "PDFCreator su Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", Collate:=True]
Application.ActivePrinter = sDefPrinter

qui a casa funziona con 01 in ufficio con 00
Ma che cos'è 00/01 ?
patrik
------------------
excel 2003 / 20007
Post: 181
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
22/02/2015 14:32

Ora funziona su Ne00 / Ne01:


Sub stampa_PDF_2()

Dim sDefPrinter As String
 sDefPrinter = Application.ActivePrinter
 
    If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne00:", Collate:=True
   
Else
    Application.ActivePrinter = "PDFCreator su Ne01:"

    ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne01:", Collate:=True

End If

Application.ActivePrinter = sDefPrinter

End Sub



E' possibile modificare perchè funzioni anche su Ne02 - Ne03 ecc ....
magari mettendo un contatore (che non so fare)?
patrik
------------------
excel 2003 / 20007
Post: 2.605
Registrato il: 28/06/2011
Città: AGORDO
Età: 70
Utente Veteran
2013
OFFLINE
22/02/2015 15:05

Non uso PDFCreator
In teoria usando dovrebbe....
If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne00:", Collate:=True
elseif Application.ActivePrinter = "PDFCreator su Ne01:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne01:", Collate:=True
elseif Application.ActivePrinter = "PDFCreator su Ne02:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne02:", Collate:=True
elseif Application.ActivePrinter = "PDFCreator su Ne03:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne03:", Collate:=True
End if
[Modificato da raffaele1953 22/02/2015 15:06]
Excel 2013
Post: 182
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
22/02/2015 20:10

Ciao raffaele,
non gira:

Sub stampa_PDF_2()
 
 If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne00:", Collate:=True
        
ElseIf Application.ActivePrinter = "PDFCreator su Ne01:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne01:", Collate:=True
        
ElseIf Application.ActivePrinter = "PDFCreator su Ne02:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne02:", Collate:=True
        
ElseIf Application.ActivePrinter = "PDFCreator su Ne03:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne03:", Collate:=True
        
End If

End Sub


patrik
------------------
excel 2003 / 20007
Post: 2.606
Registrato il: 28/06/2011
Città: AGORDO
Età: 70
Utente Veteran
2013
OFFLINE
23/02/2015 07:58

Ho descritto la dinamica dell'elseif che eseguira una sola di quelle 4 azioni.
Se la Tua con un solo if funzionava, non vedo perchè non debba funzionare con più IF.

Ps, naturale che gli mancava alcune righe. Come detto non posso provare.
Sub stampa_PDF_4()
Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter
......
......
......
Application.ActivePrinter = sDefPrinter
End Sub

Excel 2013
Post: 183
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
23/02/2015 19:03

Ciao,
ho provato la macro2 in ufficio ma non gira dà errore.
Qui a casa funziona Ne01 in ufficio Ne00.
Lo stesso per la macro3 di raffaele.
Allego l'esempio.
patrik
------------------
excel 2003 / 20007
Post: 2.608
Registrato il: 28/06/2011
Città: AGORDO
Età: 70
Utente Veteran
2013
OFFLINE
23/02/2015 20:41

Stavo rivedendo il Tuo codice
>>>If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then

Quel =true prima di Then non ci dovrebbe essere? Credo
Excel 2013
Post: 184
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
12/03/2015 22:13

Ciao,
un aiuto per far girare la macro:


Option Explicit

Sub stampa_PDF_3()

Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter


If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne00:", Collate:=True
         
ElseIf Application.ActivePrinter = "PDFCreator su Ne01:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne01:", Collate:=True
         
ElseIf Application.ActivePrinter = "PDFCreator su Ne02:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne02:", Collate:=True
         
ElseIf Application.ActivePrinter = "PDFCreator su Ne03:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne03:", Collate:=True
         
End If

Application.ActivePrinter = sDefPrinter

End Sub




patrik
------------------
excel 2003 / 20007
Post: 244
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
26/10/2016 22:33

Ciao,
ho visto in un post di oggi una richiesta simile alla mia di qualche tempo fa.
E' possibile modificare questa macro perchè funzioni?:

Option Explicit
 
Sub stampa_PDF_3()
 
Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter
 
 
If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne00:", Collate:=True
          
ElseIf Application.ActivePrinter = "PDFCreator su Ne01:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne01:", Collate:=True
          
ElseIf Application.ActivePrinter = "PDFCreator su Ne02:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne02:", Collate:=True
          
ElseIf Application.ActivePrinter = "PDFCreator su Ne03:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
        "PDFCreator su Ne03:", Collate:=True
          
End If
 
Application.ActivePrinter = sDefPrinter
 
End Sub




patrik
------------------
excel 2003 / 20007
Post: 897
Registrato il: 06/04/2013
Utente Senior
2010
OFFLINE
27/10/2016 10:33

Ciao
se ti riferisci a questa discussione:

http://www.freeforumzone.com/d/11322230/stampa-PDF/discussione.aspx

basta che copi il codice al posto del tuo.

Se ottieni errori dicci quale e dove.

saluti
Domenico
Win 10 - Excel 2016
Post: 245
Registrato il: 08/01/2012
Città: MILANO
Età: 56
Utente Junior
excel 2000/2007
OFFLINE
27/10/2016 21:04

Ciao domenico.
La tua macro nell'altro post/discussione è perfetta [SM=g27811] .
La mia era solo una curiosità per la macro di cui sopra postata, non ho mai capito perchè non vuole girare.
Non dà nessun errore e non si avvia.
Forse colpa degli elseif end if non messi nel posto giusto. [SM=g27826]
Un grazie in anticipo.
patrik01
[Modificato da patrik01 27/10/2016 21:05]
------------------
excel 2003 / 20007
Post: 905
Registrato il: 06/04/2013
Utente Senior
2010
OFFLINE
28/10/2016 09:46

Ciao
mi sembra chiaro: tutte le tue if e ElseIf testano se la stampante attiva è PDF...

If Application.ActivePrinter = "PDFCreator ....

ElseIf Application.ActivePrinter = "PDFCreator

ecc..ecc

quindi se la stampante attiva non è PDF esce senza stampare.

E' come se tu avessi:

A= X
e poi fai:
If A= B then
If A= C then
If A= D then
...


saluti
[Modificato da dodo47 28/10/2016 09:47]
Domenico
Win 10 - Excel 2016
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 10:50. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com