OVH Cloud OVH Cloud

URGENTISSIME!!!!!!!papersize

2 réponses
Avatar
christophe
bonjour a tous,

existe t'il un moyen par vba de definir un format de papier specifique.
par exemple lors de ma pagesetup j'ai les lignes suivante

.PaperSize = xlUserDefined
mais si je transfere ma macro sur un autre pc le userdefined sera vide
alros comment puis-je faire

2 réponses

Avatar
michdenis
Bonjour Christophe,

Je ne crois pas que la chose soit possible par VBA.

Tu peux cependant contourner la difficulté en définissant 2 imprimantes chacune avec un format de papier pré-établi. Selon le format
de papier désiré, tu choisis l'imprimante par défaut avec laquelle tu veux imprimer ton document.

Après avoir défini tes 2 imprimantes tu pourrais utiliser une procédure comme celle-ci :


'-----------------------------------
Sub Imprimer()

Dim NomImprimante As String
NomImprimante = "HP DeskJet 930C/932C/935C"

'Définit l'imprimante par défaut
Application.ActivePrinter = NomImprimante & " sur LPT1:"

'Affiche les dimensions du papier de cette imprimante
'au besoin

'cette section est applicable pour les systèmes d'exploitation suivant :
'scripts are designed to run with either Windows 2000, Windows XP,
'or Windows Server 2003, although many will also run on Windows NT 4.0
'or Windows 98; in the latter two cases, however, you might need to
'install additional scripting technologies such as ADSI or WMI
'before the scripts will work

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_PrinterConfiguration")
For Each objPrinter In colInstalledPrinters
If objPrinter.Name = NomImprimante Then
MsgBox "La dimension du papier est : " & vbCrLf & _
"Hauteur: " & objPrinter.PaperLength / 254 & vbCrLf & _
"Largeur: " & objPrinter.PaperWidth / 254
End If
Next

End Sub
'-----------------------------------



Salutations!







"christophe" a écrit dans le message de news:
bonjour a tous,

existe t'il un moyen par vba de definir un format de papier specifique.
par exemple lors de ma pagesetup j'ai les lignes suivante

.PaperSize = xlUserDefined
mais si je transfere ma macro sur un autre pc le userdefined sera vide
alros comment puis-je faire
Avatar
christophe
re:
Merci pour ta réponse
je vais de ce pas essayer ta procédure

a+

christophe


Bonjour Christophe,

Je ne crois pas que la chose soit possible par VBA.

Tu peux cependant contourner la difficulté en définissant 2 imprimantes chacune avec un format de papier pré-établi. Selon le format
de papier désiré, tu choisis l'imprimante par défaut avec laquelle tu veux imprimer ton document.

Après avoir défini tes 2 imprimantes tu pourrais utiliser une procédure comme celle-ci :


'-----------------------------------
Sub Imprimer()

Dim NomImprimante As String
NomImprimante = "HP DeskJet 930C/932C/935C"

'Définit l'imprimante par défaut
Application.ActivePrinter = NomImprimante & " sur LPT1:"

'Affiche les dimensions du papier de cette imprimante
'au besoin

'cette section est applicable pour les systèmes d'exploitation suivant :
'scripts are designed to run with either Windows 2000, Windows XP,
'or Windows Server 2003, although many will also run on Windows NT 4.0
'or Windows 98; in the latter two cases, however, you might need to
'install additional scripting technologies such as ADSI or WMI
'before the scripts will work

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_PrinterConfiguration")
For Each objPrinter In colInstalledPrinters
If objPrinter.Name = NomImprimante Then
MsgBox "La dimension du papier est : " & vbCrLf & _
"Hauteur: " & objPrinter.PaperLength / 254 & vbCrLf & _
"Largeur: " & objPrinter.PaperWidth / 254
End If
Next

End Sub
'-----------------------------------



Salutations!







"christophe" a écrit dans le message de news:
bonjour a tous,

existe t'il un moyen par vba de definir un format de papier specifique.
par exemple lors de ma pagesetup j'ai les lignes suivante

..PaperSize = xlUserDefined
mais si je transfere ma macro sur un autre pc le userdefined sera vide
alros comment puis-je faire