我用如下方法打印图片:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command5_Click()
strFilePaths = "C:\7.JPG,C:\2.htm,C:\sample.tiff"
strFilePaths = Split(strFilePaths, ",")
For intCount = 0 To UBound(strFilePaths)
ShellExecute Me.hwnd, "print", strFilePaths(intCount), vbNullString, vbNullString, 0
Next
End Sub1、打印图片时只将图片显示出来而不打印。是不是和操作系统有关啊?
2、打印htm时不能将网页中的图片打印出来。
3、当文件路径有错时,例如:strFilePaths = "C:\7.JPG,a,C:\sample.tiff"
如何能捕捉这个错误,将错误信息或错误的文件路径名显示出来。本人初学vb,最好能给代码。谢谢!
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command5_Click()
strFilePaths = "C:\7.JPG,C:\2.htm,C:\sample.tiff"
strFilePaths = Split(strFilePaths, ",")
For intCount = 0 To UBound(strFilePaths)
ShellExecute Me.hwnd, "print", strFilePaths(intCount), vbNullString, vbNullString, 0
Next
End Sub1、打印图片时只将图片显示出来而不打印。是不是和操作系统有关啊?
2、打印htm时不能将网页中的图片打印出来。
3、当文件路径有错时,例如:strFilePaths = "C:\7.JPG,a,C:\sample.tiff"
如何能捕捉这个错误,将错误信息或错误的文件路径名显示出来。本人初学vb,最好能给代码。谢谢!
dim strFilePaths as string
dim strFilePathsArr() as string
strFilePaths = "C:\7.JPG,C:\2.htm,C:\sample.tiff"
strFilePathsArr= Split(strFilePaths, ",")
For intCount = 0 To UBound(strFilePathsArr)
ShellExecute Me.hwnd, "print", strFilePathsArr(intCount), vbNullString, vbNullString, 0
Next
End Sub
如何能捕捉这个错误,将错误信息或错误的文件路径名显示出来。//用错误处理
On error goto errHandle
'正常操作
errHandle:
'错误处理的提示或者其他操作
resume next '继续执行
比如对于pdf文件用pdf.ocx:Private Sub Command1_Click()
Dim xx As New Pdf
xx.LoadFile ("c:\1.pdf")
xx.printAll
End Sub
(执行后应用程序无相应):(对于html,jpg,gif,tiff有没有相应方法呢?