碰到这样一个棘手的问题,在vb程序中要打印一个web网页(例如:http://www.csdn.net),并且需要选择非默认的打印机(比如:默认打印机为A,另外一台打印机为B,要在B上面进行打印),自动地打印出来。
我已经试过如下方法:InternetExplorer控件可以显示出来web网页,但是不可以选择非默认的打印机并且自动打印出来;Printer组件可以选择非默认的打印机,但是无法打印web网页,只能够打印字符串。
不知道那位大哥碰到这样类似的问题,谢谢了!

解决方案 »

  1.   

    http://topic.csdn.net/t/20040716/14/3181353.html
      

  2.   

    谢谢CathySun118(斯年),帖子中的内容,我在问问题之前均尝试过的,不能够达到要求的。
      

  3.   

    如下代码,可以直接打印htm的,但是无法选择非默认打印机,进行自动打印的。
    Private Function PrintWebPage(ByVal URL As String) As Boolean
         Dim sFile As String
         sFile = SystemDir & "\MSHTML.DLL"
         'check if .dll to print page exists
         If Dir(sFile) = "" Then Exit Function
         On Error Resume Next
         Shell "rundll32.exe """ & sFile & """,PrintHTML """ & URL & """", vbNormalFocus
         'return true if no errors
         PrintWebPage = Err.Number = 0
    End FunctionPrivate Function SystemDir() As String
        Dim sRet As String, lngRet As Long
        sRet = String$(MAX_PATH, 0)
        lngRet = GetSystemDirectory(sRet, MAX_PATH)
        SystemDir = Left(sRet, lngRet)
    End Function