因为我想通过WebBrowser批量下载一些服务器端根据提交表单而动态生成的报表(格式为.xls)。
希望大家给个最短的有效的关键代码例子。
语言限制:VB6(因为要在Excel 2003的VBA中使用)
不要告诉我使用vbMHWB,因为它需要处理的情况太多,而原程序中已经有大量代码,在WebBrowser下写的。
olelib.tlb我已经下载了一份,可是不会用,通过引用加入.tlb后,Dim A As olelib.这样的方式,也看不到里面有IDownloadManager。关键就在于如何实现这个接口,不会啊。

解决方案 »

  1.   

    为什么要用WebBrowser下载呢?自己使用xmlhttp下载不就不显示另存为对话框了吗?
      

  2.   

    为什么要用WebBrowser呢?因为我已经用上了用了很久了,写了很多功能,我希望将这个整合于其中。还有我不知道如何判断动态生成的文件的URL,也不想拦住所有的下载,仅仅是在某特定的应用中,加入批量保存报表的功能。每次问问题都是很累啊,总有些劝你换大背景的朋友啊,各位我做这种选择有种种原因不能改,定然是要问本前提下的解,真是很浪费感情啊!
      

  3.   

    Implements olelib.IDownloadManager是这样使用的。
    不过,直接这样写上是不会有效果的,还得Implements olelib2.IServiceProvider
    然后在IServiceProvider_QueryService中根据guidService和riid来判断,当查询IDownloadManager的时候做出相应的处理。做到这里即可响应IDownloadManager_Download在IDownloadManager_Download中,真正返回s_ok即可取消下载。
    看结构:
    Private Sub IDownloadManager_Download(ByVal pmk As olelib.IMoniker, ByVal pbc As olelib.IBindCtx, ByVal dwBindVerb As Long, ByVal grfBINDF As Long, pbindinfo As olelib.BINDINFO, ByVal pszHeaders As Long, ByVal pszRedir As Long, ByVal uiCP As Long)End Sub用pmk.GetDisplayName(pbc, Nothing)即可得到下载URL的地址取消下载后,根据URL再选择合适的方法下载。简单说来就是这样。
      

  4.   

    http://www.mvps.org/emorcillo/download/vb6/tl_ole.zip中无IDownloadManager,按lingll给出的定义去(他原意是指将那个存成downloadmgr.inc吗?)编译olelib.odl,结果是:
    Processing .\olelib.odl
    Processing C:\Program Files\Microsoft Visual Studio\VC98\include\oaidl.idl
    Processing C:\Program Files\Microsoft Visual Studio\VC98\include\objidl.idl
    Processing C:\Program Files\Microsoft Visual Studio\VC98\include\unknwn.idl
    Processing C:\Program Files\Microsoft Visual Studio\VC98\include\wtypes.idl
    .\downloadmgr.inc(13) : error MIDL2025 : syntax error : expecting a type specification near "BINDINFO"
    .\downloadmgr.inc(13) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation 不知道BINDINFO这样的定义在.odl中怎么样写?