Canibool
Messages postés4Date d'inscriptionmardi 17 octobre 2006StatutMembreDernière intervention31 août 2007
-
31 août 2007 à 14:50
Canibool
Messages postés4Date d'inscriptionmardi 17 octobre 2006StatutMembreDernière intervention31 août 2007
-
31 août 2007 à 17:06
bonjour,
je cherche un moyen d'imprimer une page html dans un .vbs.
le
contexte est le suivant: j'ai programme écrit dans un autre langage qui
génère des bons de commande en html. ce programme appelle un script
.vbs qui se charge d'imprimer cette page.
le script ne fait pas
seulement qu'imprimer (même si c'est là qu'est mon problème). il
configure un fax en imprimante par défaut, et des bidouilles de config
du fax... ah oui parcequ'en c'est pas vraiment une impression, c'est un
envoi de fax... mais il faut imprimer le document sur le fax pour qu'il
soit envoyé.
j'avais essayé de faire ça avec un .pdf au lieu du
html. c'est possible mais pour ça il faut acrobat payant (pour utiliser
acroexch, une dll).
donc j'ai toujours pas de solution avec html
car je n'ai pas trouvé de dll à invoquer pour imprimer (IE ou mozilla),
ni de fonction PRINT à utiliser par un objet quelconque.
alors si quelqu'un à une astuce je suis preneur.
je vous montre le script pour faciliter la tâche:
Dim strComputer
Dim strDefPrinter
Dim net
Dim iTemp
Dim sPrinter
Dim FaxNum
Dim hnd
Dim ret
Dim WshShell
dim oldDefPrinter
Dim DefPrinter
Dim oFso
Dim oFile
FaxNum = "6726"
strComputer = "."
strDefPrinter = ""
Set net = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery ("Select * from Win32_Printer")
For Each objPrinter in colInstalledPrinters
if instr(1,objPrinter.Name,"RICOH")<>0 then
strDefPrinter = objPrinter.Name
end if
Next
net.SetDefaultPrinter strDefPrinter
Set WshShell = WScript.CreateObject ("WScript.Shell")
hnd = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxOpen " & strDefPrinter,1,true)
Wscript.Echo hnd
ret = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxSender " & hnd & " 1 " & FaxNum,1,true)
Wscript.Echo ret
ret = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxTTI " & hnd & " " & IFX_TTI_ON,1,true)
Wscript.Echo ret
ret = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxLock " & hnd,1,true)
Wscript.Echo ret
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oFile = oFso.GetFile("D:\opt\oracle\cde.htm")
--là il faudrait imprimer
ret = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxUnlock " & hnd,1,true)
Wscript.Echo ret
ret = WshShell.Run("%windir%\system32\RUNDLL32.EXE Ifxapi32.dll,IfxClose " & hnd,1,true)
Wscript.Echo ret
Function fnImprimerDoc(MyDoc)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer")
If colInstalledPrinters.Count <> 0 Then
For Each objPrinter in colInstalledPrinters
If Left(objPrinter.DeviceID,9) <> "Microsoft" Then
'WScript.Echo "Name: " & objPrinter.Name &vbCr&_
' "Default: " & objPrinter.Default &vbCr&_
' "Port: " & objPrinter.PortName &vbCr&_
' "Imprimante Reseau: " & objPrinter.Network
'ICI il faut rajouter un "Select Case" des imprimantes réseaux
Dim objFso, objWordApp, objWordDoc
Set objFso = CreateObject("Scripting.FileSystemObject")
If objFso.FileExists(MyDoc) Then
Set objWordApp = CreateObject("Word.Application")
Set objWordDoc = objWordApp.documents.open(MyDoc)
objWordApp.ActivePrinter=objPrinter.Name
objWordDoc.PrintOut 0
objWordDoc.Close
objWordApp.Quit
Set objWordApp = Nothing
Set objWordDoc = Nothing
MsgBox "coucou"
End if
Set objFso = Nothing
End if
Next
End If
Set objWMIService = Nothing
Set colInstalledPrinters = Nothing
End Function