我用如下方法打印图片:
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,最好能给代码。谢谢!

解决方案 »

  1.   

    Private Sub Command5_Click()
    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
      

  2.   

    TO:lxcc(虫子|专注于抢分)先谢谢你啊!你写的和你之前给我的没什么区别啊?我列的那三个问题还是不能解决啊!
      

  3.   

    3、当文件路径有错时,例如:strFilePaths = "C:\7.JPG,a,C:\sample.tiff"
       如何能捕捉这个错误,将错误信息或错误的文件路径名显示出来。//用错误处理
    On error goto errHandle
        '正常操作
    errHandle:
        '错误处理的提示或者其他操作
        resume next    '继续执行
      

  4.   

    ShellExecute消耗资源较大,能不能用其他方法。
    比如对于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有没有相应方法呢?
      

  5.   

    pdf.ocx用5.0的,6.0的不好使!!!!