| | Post: 708 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
25/12/2016 14:14 | |
Ciao a tutti e buon natale,
Ho una curiosità per stampare in pdf
Questa macro funziona a casa ma non in ufficio:
'solo casa
Sub stampa_PDF()
Dim sDefPrinter As String
ActiveSheet.Unprotect "123456"
sDefPrinter = Application.ActivePrinter
If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne00:", Collate:=True
Application.ActivePrinter = sDefPrinter
Else
Application.ActivePrinter = "PDFCreator su Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", Collate:=True
Application.ActivePrinter = sDefPrinter
End If
ActiveSheet.Protect "123456"
End Sub
questa funziona solo in ufficio:
'solo ufficio
Sub stampa_PDF()
Dim avviso As String
ActiveSheet.Unprotect "123456"
Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter
Application.ActivePrinter = "PDFCreator su Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne00:", Collate:=True
Application.ActivePrinter = sDefPrinter
End Sub
A casa su Ne01 in ufficio su Ne00.
la prima in teoria dovrebbe funazionare sia a casa che in ufficio ma non è così.
Un aiuto perchè funzioni sia a casa che in ufficio?
Grazie.
max
____________________________
versione excel 365 ufficio
versione excel 2007 casa |
|
| | Post: 708 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
25/12/2016 14:39 | |
Se inverto nella prima macro Ne00/Ne01
allora non funziona a casa ma in ufficio:
If Application.ActivePrinter = "PDFCreator su Ne00:" = True Then '<<<<<<<<
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne00:", Collate:=True
Application.ActivePrinter = sDefPrinter
Else
Application.ActivePrinter = "PDFCreator su Ne01:" '<<<<<<
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", Collate:=True
max [Modificato da maxma62 25/12/2016 14:39] ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 709 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
25/12/2016 20:34 | |
Ciao,
questa macro trovata in rete risolve (spero) il problema del numero della stampante
Sub stampa_PDF()
Dim c As Integer, strPrinterName As String
On Error Resume Next
For c = 1 To 10
PrinterName = "PDFCreator su Ne0" & c & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
PrinterName, collate:=True
Next c
On Error GoTo 0
End Sub
funziona in parte, stampa 10 volte ( For c = 1 To 10) il foglio pdf,
Un aiuto correggerla?
max ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 2.511 | Registrato il: 21/06/2013
| Città: NAPOLI | Età: 70 | Utente Veteran | Excel 365 | | OFFLINE |
|
25/12/2016 21:44 | |
Ciao Max
Se devi stampare una sola copia devi togliere il ciclo For.
Cancella le righe For c e Next c
Alfredo |
| | Post: 710 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
25/12/2016 21:59 | |
Ciao alfredo,
è o.k.
max [Modificato da maxma62 25/12/2016 22:43] ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 711 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 08:49 | |
Ciao,
non parte la stampante PDF
Sub stampa_PDF_3()
Dim c As Integer, PrinterName As String
On Error Resume Next
'For c = 1 To 10
PrinterName = "PDFCreator su Ne0" & c & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
PrinterName, collate:=True
'Next c
On Error GoTo 0
End Sub
max
____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 1.047 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
26/12/2016 09:22 | |
Ciao
prova ad utilizzare il codice da me proposto nella seguente discussione:
http://www.freeforumzone.com/d/11322230/stampa-PDF/discussione.aspx
saluti
[Modificato da dodo47 26/12/2016 09:23] Domenico
Win 10 - Excel 2016 |
| | Post: 712 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 09:55 | |
Grazie domenico,
direi che funziona.
Una piccola modifica alla tua macro (non so se è esatto)
------------------------
Next
Application.ActivePrinter = "PDFCreator su Ne" & Format(lng, "00") & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne" & Format(lng, "00") & ":", Collate:=True
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
End With
Application.ActivePrinter = sDefPrinter
--------------------------
dovrebbe centrare la tabella nel foglio.
Funaziona ma dopo la chiusura mi resta impostato in imposta pagina.
La macro deve farlo solo nella macro stampapdf.
Spero di essermi spiegato.
Grazie a tutti.
max
____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 1.048 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
26/12/2016 10:07 | |
Ciao
intanto devi impostare la centratura "prima" della stampa, poi dovrebbe essere sufficiente rimettere a false i parametri:
...
...
Next
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
End With
Application.ActivePrinter = "PDFCreator su Ne" & Format(lng, "00") & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne" & Format(lng, "00") & ":", Collate:=True
With ActiveSheet.PageSetup
.CenterHorizontally = False
.CenterVertically = False
End With
Application.ActivePrinter = sDefPrinter
End Sub
saluti [Modificato da dodo47 26/12/2016 10:09] Domenico
Win 10 - Excel 2016 |
| | Post: 713 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 13:42 | |
Ciao domenico,
funziona tutto. .
Grazie,
max [Modificato da maxma62 26/12/2016 14:31] ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 714 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 14:47 | |
Ciao,
la macro ultima è ok.
C'è qualcosa che non va.
Nle workbook c'è un'immagine/logo che non vuole spamparsi se è attivo qui:
'-----------------------------
'With ActiveSheet.PageSetup '<<<<<
'.CenterHorizontally = True '<<<<<
'.CenterVertically = True '<<<<<
'End With
Application.ActivePrinter = "PDFCreator su Ne" & Format(lng, "00") & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne" & Format(lng, "00") & ":", collate:=True
'ok
With ActiveSheet.PageSetup
.CenterHorizontally = False
.CenterVertically = False
End With
'-----------------------------
la macro completa:
Option Explicit
Sub stampa_PDF()
Dim sDefPrinter As String
Dim lng As Long
Application.ScreenUpdating = False
ActiveSheet.Unprotect "123456"
sDefPrinter = Application.ActivePrinter
On Error Resume Next
For lng = 0 To 30 'dovrebbe bastare....
If InStr(ActivePrinter, "PDFCreator") Then
Exit For
Else
ActivePrinter = "PDFCreator su Ne" & Format(lng, "00") & ":"
End If
Next
'With ActiveSheet.PageSetup
'.CenterHorizontally = True
'.CenterVertically = True
'End With
Application.ActivePrinter = "PDFCreator su Ne" & Format(lng, "00") & ":"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne" & Format(lng, "00") & ":", collate:=True
'ok
With ActiveSheet.PageSetup
.CenterHorizontally = False
.CenterVertically = False
End With
Application.ActivePrinter = sDefPrinter
Application.ScreenUpdating = True
ActiveSheet.Protect "123456"
End Sub
max
____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 715 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 18:08 | |
Provato su un'altra macro:
Sub stampa_PDF()
Application.ScreenUpdating = False
ActiveSheet.Unprotect "123456"
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
End With
Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter
Application.ActivePrinter = "PDFCreator su Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", collate:=True
Application.ActivePrinter = sDefPrinter
With ActiveSheet.PageSetup
.CenterHorizontally = False
.CenterVertically = False
End With
Application.ScreenUpdating = True
ActiveSheet.Protect "123456"
End Sub
e anche in questa:
With ActiveSheet.PageSetup '<<<<
.CenterHorizontally = True '<<<<
.CenterVertically = True '<<<<
End With
Dim sDefPrinter As String
sDefPrinter = Application.ActivePrinter
Application.ActivePrinter = "PDFCreator su Ne01:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", collate:=True
Application.ActivePrinter = sDefPrinter
With ActiveSheet.PageSetup '<<<
.CenterHorizontally = False '<<<
.CenterVertically = False '<<<
End With
se attivi non fanno stampare l'immagine/logo che dicevo qualche risposta più indietro.
max
____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 1.049 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
26/12/2016 18:30 | |
Ciao
non saprei cosa dirti, io ho inserito immagini e forme e non ho avuto problemi....
saluti
Domenico
Win 10 - Excel 2016 |
| | Post: 716 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
26/12/2016 22:21 | |
Ho eliminato dal foglio l'immagine/logo con un'altra e ora funziona.
Misteri...
Comunque grazie a tutti, domenico e alfredo.
Un saluto.
max ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 718 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
27/12/2016 18:03 | |
Salve,
una mia curiosità sempre per stampare in pdf.
La macro di domenico (dodo47) funziona e spulcando nelle varie macro ho trovato questa che non ha mai funzionato:
Sub stampa_PDF()
Dim sDefPrinter As String
'ActiveSheet.Unprotect "123456"
sDefPrinter = Application.ActivePrinter
If Application.ActivePrinter = "PDFCreator su Ne01:" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne01:", Collate:=True
Application.ActivePrinter = sDefPrinter
ElseIf Application.ActivePrinter = "PDFCreator su Ne02:" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne02:", Collate:=True
Application.ActivePrinter = sDefPrinter
ElseIf Application.ActivePrinter = "PDFCreator su Ne04:" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne04:", Collate:=True
Application.ActivePrinter = sDefPrinter
Else
Application.ActivePrinter = "PDFCreator su Ne03:" ' Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"PDFCreator su Ne03:", Collate:=True
Application.ActivePrinter = sDefPrinter
End If
'Application.ActivePrinter = sDefPrinter
'ActiveSheet.Protect "123456"
End Sub
un aiuto per correggerla?.
max ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
| | Post: 1.050 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
27/12/2016 18:59 | |
Ciao
segui in debug la MIA macro e quando esce dal loop For lng...Next, controlla il valore di lng, se non è compreso tra 1 e 4 è ovvio che la tua macro non funziona.
Comunque l'uso del tuo metodo non va bene, perché PdfCreator potrebbe stare su una qualsiasi delle porte...
saluti Domenico
Win 10 - Excel 2016 |
| | Post: 719 | Registrato il: 28/12/2009
| Città: CITTADELLA | Età: 62 | Utente Senior | excel 2007/365 | | OFFLINE | |
|
27/12/2016 19:27 | |
Grazie domenico.
max ____________________________
versione excel 365 ufficio
versione excel 2007 casa |
|
|