Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Imprimer automatiquement sur un fichier PDF

8 réponses
Avatar
EmanuelL
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le
convertir en fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org

8 réponses

Avatar
papou
Bonjour
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
Dim ImpSAV As String

ImpSAV = Application.ActivePrinter
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
Dim ImpPdf As String

ImpPdf = "PDFCreator sur NE00:"
Application.ActivePrinter = ImpPdf
- Comment remettre l'ancienne inprimante par defaut?
Application.ActivePrinter = ImpSAV


Cordialement
Pascal


"EmanuelL" a écrit dans le message de news:

Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir
en fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org




Avatar
Modeste
Bonsour® EmanuelL avec ferveur ;o))) vous nous disiez :

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?


Sub Change_printer()
printerold = Application.ActivePrinter
MsgBox "L'imprimante active actuelle est : " _
& " >>>>> " & printerold

dlganswer = Application.Dialogs(xlDialogPrinterSetup).Show
If dlganswer = True Then
reponse = MsgBox("L'imprimante active était : " _
& Chr(10) & " ====> " & printerold _
& Chr(10) & " elle sera maintenant : " _
& Chr(10) & " ====> " & Application.ActivePrinter _
& Chr(10) & "Voulez vous confirmer ?", _
vbQuestion + vbYesNo, _
"Changement d'imprimante")
If reponse = vbYes Then
MsgBox "L'imprimante active actuelle devient : " _
& Chr(10) & " ====> "& Application.ActivePrinter
Exit Sub
End If
Else
Application.ActivePrinter = printerold
MsgBox "L'imprimante active actuelle reste : " _
& Chr(10) & " ====> "& printerold
End If
End Sub


@+
;o)))

Avatar
EmanuelL
Nickel, je tests, merci à tous les deux.
A+

EmanuelL a formulé la demande :
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir en
fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)


--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org

Avatar
EmanuelL
Papou,

J'ai l'erreur ci-joint, cidessous :
http://cjoint.com/confirm.php?cjoint=lAqPke1lQL

Private Sub cmbImprimerFiche_Click()
Dim ImpSAV As String
ImpSAV = Application.ActivePrinter
ImpPdf = "PDFCreator"
' IL SE PLANTE ICI, j'ai bien l'imprimante PDECreator dans la liste
des mes imprimantes, mais! :'(
Application.ActivePrinter = ImpPdf

ufmOuvertureClient.PrintForm
Application.ActivePrinter = ImpSAV
End Sub

De quoi s'agit-il?
Merci d'avance.


Le 26.11.2007, papou a supposé :
Bonjour
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
Dim ImpSAV As String

ImpSAV = Application.ActivePrinter
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
Dim ImpPdf As String

ImpPdf = "PDFCreator sur NE00:"
Application.ActivePrinter = ImpPdf
- Comment remettre l'ancienne inprimante par defaut?
Application.ActivePrinter = ImpSAV


Cordialement
Pascal


"EmanuelL" a écrit dans le message de news:

Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir en
fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org


Avatar
papou
Bonjour
Il s'agit d'un problème d'identification du port de l'imprimante.
Pour faire court :
Tu définis provisoirement l'imprimante PDFCreator comme imprimante par
défaut
Tu vas dans Excel et tu écris ce code dans une macro provisoire :
Sub zozo()
Msgbox Application.ActivePrinter
End Sub
Tu exécutes la macro et tu notes précisément le nom qui s'affiche
Tu pourras alors modifier ta macro afin d'utiliser le libellé exact de
l'imprimante PDFCreator.

Cordialement
Pascal


"EmanuelL" a écrit dans le message de news:

Papou,

J'ai l'erreur ci-joint, cidessous :
http://cjoint.com/confirm.php?cjoint=lAqPke1lQL

Private Sub cmbImprimerFiche_Click()
Dim ImpSAV As String
ImpSAV = Application.ActivePrinter
ImpPdf = "PDFCreator"
' IL SE PLANTE ICI, j'ai bien l'imprimante PDECreator dans la liste des
mes imprimantes, mais! :'(
Application.ActivePrinter = ImpPdf

ufmOuvertureClient.PrintForm
Application.ActivePrinter = ImpSAV
End Sub

De quoi s'agit-il?
Merci d'avance.


Le 26.11.2007, papou a supposé :
Bonjour
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
Dim ImpSAV As String

ImpSAV = Application.ActivePrinter
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
Dim ImpPdf As String

ImpPdf = "PDFCreator sur NE00:"
Application.ActivePrinter = ImpPdf
- Comment remettre l'ancienne inprimante par defaut?
Application.ActivePrinter = ImpSAV


Cordialement
Pascal


"EmanuelL" a écrit dans le message de
news:
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir
en fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org






Avatar
EmanuelL
Bonjour Papou,

Hier j'étais absent, je tests.

Merci. ;-)


papou a présenté l'énoncé suivant :
Bonjour
Il s'agit d'un problème d'identification du port de l'imprimante.
Pour faire court :
Tu définis provisoirement l'imprimante PDFCreator comme imprimante par défaut
Tu vas dans Excel et tu écris ce code dans une macro provisoire :
Sub zozo()
Msgbox Application.ActivePrinter
End Sub
Tu exécutes la macro et tu notes précisément le nom qui s'affiche
Tu pourras alors modifier ta macro afin d'utiliser le libellé exact de
l'imprimante PDFCreator.

Cordialement
Pascal


"EmanuelL" a écrit dans le message de news:

Papou,

J'ai l'erreur ci-joint, cidessous :
http://cjoint.com/confirm.php?cjoint=lAqPke1lQL

Private Sub cmbImprimerFiche_Click()
Dim ImpSAV As String
ImpSAV = Application.ActivePrinter
ImpPdf = "PDFCreator"
' IL SE PLANTE ICI, j'ai bien l'imprimante PDECreator dans la liste des
mes imprimantes, mais! :'(
Application.ActivePrinter = ImpPdf

ufmOuvertureClient.PrintForm
Application.ActivePrinter = ImpSAV
End Sub

De quoi s'agit-il?
Merci d'avance.


Le 26.11.2007, papou a supposé :
Bonjour
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
Dim ImpSAV As String

ImpSAV = Application.ActivePrinter
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
Dim ImpPdf As String

ImpPdf = "PDFCreator sur NE00:"
Application.ActivePrinter = ImpPdf
- Comment remettre l'ancienne inprimante par defaut?
Application.ActivePrinter = ImpSAV


Cordialement
Pascal


"EmanuelL" a écrit dans le message de
news:
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir
en fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org




Avatar
EmanuelL
Papou,

Juste un problème, il m'affiche bien "PDFCreator sur Ne04:" seulement
le numéro de Nexx semble être aléatoire d'un PC à un'autre.

Sais-Tu comment PDFCreator ou Windows genère ce Nexx, il est mémorisé
ou?

Merci encore de ton assistance. ;-)

papou avait prétendu :
Bonjour
Il s'agit d'un problème d'identification du port de l'imprimante.
Pour faire court :
Tu définis provisoirement l'imprimante PDFCreator comme imprimante par défaut
Tu vas dans Excel et tu écris ce code dans une macro provisoire :
Sub zozo()
Msgbox Application.ActivePrinter
End Sub
Tu exécutes la macro et tu notes précisément le nom qui s'affiche
Tu pourras alors modifier ta macro afin d'utiliser le libellé exact de
l'imprimante PDFCreator.

Cordialement
Pascal


"EmanuelL" a écrit dans le message de news:

Papou,

J'ai l'erreur ci-joint, cidessous :
http://cjoint.com/confirm.php?cjoint=lAqPke1lQL

Private Sub cmbImprimerFiche_Click()
Dim ImpSAV As String
ImpSAV = Application.ActivePrinter
ImpPdf = "PDFCreator"
' IL SE PLANTE ICI, j'ai bien l'imprimante PDECreator dans la liste des
mes imprimantes, mais! :'(
Application.ActivePrinter = ImpPdf

ufmOuvertureClient.PrintForm
Application.ActivePrinter = ImpSAV
End Sub

De quoi s'agit-il?
Merci d'avance.


Le 26.11.2007, papou a supposé :
Bonjour
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
Dim ImpSAV As String

ImpSAV = Application.ActivePrinter
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
Dim ImpPdf As String

ImpPdf = "PDFCreator sur NE00:"
Application.ActivePrinter = ImpPdf
- Comment remettre l'ancienne inprimante par defaut?
Application.ActivePrinter = ImpSAV


Cordialement
Pascal


"EmanuelL" a écrit dans le message de
news:
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir
en fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)

--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org





--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org




Avatar
EmanuelL
Bonjour,

Voilà ce que j'ai fini par créer pour générer un fichier PDF en mode
silence. Toute critique est le bienvenue. ;-)

'-- Definition de l'imprimante par defaut --
Private Declare Function SetDefaultPrinter Lib "winspool.drv" _
Alias "SetDefaultPrinterA" _
(ByVal pszPrinter As String) As Long

'-- Restitution de la liste des imprimantes --
Private Declare Function GetProfileString Lib "kernel32" _
Alias "GetProfileStringA" _
(ByVal lpAppName As String, _
ByVal lpKeyName As String, _
ByVal lpDefault As String, _
ByVal lpReturnedString As String, _
ByVal nSize As Long) As Long

'-- Recuperation du nom de l'imprimante par defaut --
Public Function DefaultPrinter() As String
Dim strReturn As String
Dim intReturn As Integer
strReturn = Space(255)
intReturn = GetProfileString("Windows", ByVal "device", "", _
strReturn, Len(strReturn))
If intReturn Then
strReturn = UCase(Left(strReturn, InStr(strReturn, ",") - 1))
End If
DefaultPrinter = strReturn
End Function

'-- Impression du fichier PDF --
Function PDFCreatorPrinting()
Dim pdfjob As Object
Dim sPDFName As String
Dim sPDFPath As String

'/// Change the output file name here! ///
If ufmOuvertureClient.txtNomClient.Value = "" Then Exit Function

Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")

With pdfjob
If .cStart("/NoProcessingAtStartup") = False Then
MsgBox "PDFCreator n'est pas installé.", vbCritical + _
vbOKOnly, "PrtPDFCreator"
Exit Function
End If

.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = CurDir()
sPDFName = "Nouv" + "_" +
ufmOuvertureClient.txtNomClient.Value + _
"_" + Format(Date, "DDMMYYYY") + Format(Time, "HHMMSS")
.cOption("AutosaveFilename") = sPDFName
.cOption("AutosaveFormat") = 0 ' 0 = PDF
.cClearCache
DoEvents
End With

lsActPrinter = DefaultPrinter()
lsDefaultPrinter = "PDFCreator"
SetDefaultPrinter lsDefaultPrinter

With ufmOuvertureClient
.KeepScrollBarsVisible = fmScrollBarsNone
.cmbCreerFiche.Visible = False
.cmbImprimerFiche.Visible = False
.cmbImprimerFicheVierge.Visible = False
.cmdEffacer.Visible = False
.cmdQuitter.Visible = False
.PrintForm
.KeepScrollBarsVisible = fmScrollBarsBoth
.cmbCreerFiche.Visible = True
.cmbImprimerFiche.Visible = True
.cmbImprimerFicheVierge.Visible = True
.cmdEffacer.Visible = True
.cmdQuitter.Visible = True
End With

SetDefaultPrinter lsActPrinter

'Wait until the print job has entered the print queue
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False

'Wait until PDF creator is finished then release the objects
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
pdfjob.cClose
Set pdfjob = Nothing
End Function

Le 26.11.2007, EmanuelL a supposé :
Bonjour à Tous,

J'ai un formulaire dans lequel j'utilise "PrintForm" pour l'imprimer,
j'aimerais l'imprimer automatiquement sur un fichier PDF ou le convertir en
fichiers PDF.

En VBA :
- Comment sauvegader le nom de l'imprimante par defaut actuelle?
- Comment mettre en PDFCreator ou autre comme imprimante par defaut?
- Comment remettre l'ancienne inprimante par defaut?

Merci d'avance. ;-)


--

*!* -----------------------------------
EmanuelL
Membre d'AtoutFox
www.atoutfox.org