Not a Member Yet,
Click here to Register

ID: 369
Viewed: 4783
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

If MSHTML.DLL Is installed In the system directory, you can use the following code :

Highlight all by clicking in box
<!---Declaration--->
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias
"GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STATUS_PENDING = &H103&

Highlight All
<!---Code--->
Public Sub PrintHtmlFile(cHtmlFile As String)
Dim hProcess As Long
Dim ProcessId As Long
Dim ExitCode As Long
Dim cWinSysDir As String
cWinSysDir = String(254, " ")
Call GetSystemDirectory(cWinSysDir, Len(cWinSysDir))
cWinSysDir = Trim(Left(cWinSysDir, InStr(cWinSysDir, Chr(0)) - 1))
If Dir(cWinSysDir & "MSHTML.DLL") <> "" Then
ProcessId = Shell("rundll32.exe " & cWinSysDir &
"MSHTML.DLL,PrintHTML " & Chr(34) & cHtmlFile & Chr(34), vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STATUS_PENDING
Call CloseHandle(hProcess)
End If
End Sub



'If MSHTML.DLL Is installed In the system directory, you can use the
'following code :


Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, lpExitCode As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Public Declare Function GetSystemDirectory Lib "kernel32" Alias
"GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STATUS_PENDING = &H103&

Public Sub PrintHtmlFile(cHtmlFile As String)
Dim hProcess As Long
Dim ProcessId As Long
Dim ExitCode As Long
Dim cWinSysDir As String
cWinSysDir = String(254, " ")
Call GetSystemDirectory(cWinSysDir, Len(cWinSysDir))
cWinSysDir = Trim(Left(cWinSysDir, InStr(cWinSysDir, Chr(0)) - 1))
If Dir(cWinSysDir & "MSHTML.DLL") <> "" Then
ProcessId = Shell("rundll32.exe " & cWinSysDir &
"MSHTML.DLL,PrintHTML " & Chr(34) & cHtmlFile & Chr(34), vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While ExitCode = STATUS_PENDING
Call CloseHandle(hProcess)
End If
End Sub;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!