Office中国论坛/Access中国论坛

标题: 问题已经解决,下载图片! [打印本页]

作者: lixun005    时间: 2008-3-18 17:15
标题: 问题已经解决,下载图片!
下载图片

[ 本帖最后由 lixun005 于 2008-3-20 11:00 编辑 ]
作者: lixun005    时间: 2008-3-18 17:30
管理员在吗?回答一下啊!谢谢喽!
作者: tmtony    时间: 2008-3-18 17:52
可以啊, 便 要写VBA代码
在窗体中插入IE控件

Dim b() As Byte
Dim strPath As String
Inet2.URL = "http://www.office-cn.net/test.jpg"
strPath = App.Path & "/tmp.bmp"
b() = Inet2.OpenURL(, icByteArray)
Open strPath For Binary Access Write As #1
    Put #1, , b()
Close #1
作者: fan0217    时间: 2008-3-18 17:57


  1. Public Sub SaveWebPicture(url As String, fileName As String)
  2. Dim x As New XMLHTTP
  3. Dim s As New ADODB.Stream
  4.     x.Open "GET", url, False
  5.     x.send
  6.     s.Type = 1
  7.     s.Open
  8.     s.Write x.responseBody
  9.     s.SaveToFile fileName
  10.     s.Close
  11.    
  12.     Set x = Nothing
  13.     Set s = Nothing
  14.   End Sub
  15. Sub Test()
  16.     SaveWebPicture "http://cimg2.163.com/mobile/2008/3/18/160_129.jpg", "C:\Test.jpg"
  17. End Sub


复制代码

作者: tmtony    时间: 2008-3-18 18:08
呵呵, 用stream也是好办法
作者: lixun005    时间: 2008-3-18 23:00
非常感谢两位,哈哈......
作者: lixun005    时间: 2008-3-19 11:08
请问一下加在铵钮上是这样用的吗?
需要加插件吗?
Private Sub Command0_Click()
    Public Sub SaveWebPicture(url As String, fileName As String)
    Dim x As New XMLHTTP
    Dim s As New ADODB.Stream
    x.Open "GET", url, False
    x.send
    s.Type = 1
    s.Open
    s.Write x.responseBody
    s.SaveToFile fileName
    s.Close
   
    Set x = Nothing
    Set s = Nothing
  End Sub
    SaveWebPicture "http://cimg2.163.com/mobile/2008/3/18/160_129.jpg", "D:\Test.jpg"
End Sub

[ 本帖最后由 lixun005 于 2008-3-19 11:36 编辑 ]
作者: fan0217    时间: 2008-3-19 13:40
Private Sub Command0_Click()
SaveWebPicture "图片url地址", "保存图片的本地地址"

  End Sub
作者: fan0217    时间: 2008-3-19 13:42
需要引用xml和ado2.5以上版本
作者: lixun005    时间: 2008-3-19 14:31
Public Sub SaveWebPicture(url As String, fileName As String)
    Dim x As New XMLHTTP
    Dim s As New ADODB.Stream
    x.Open "GET", url, False
    x.send
    s.Type = 1
    s.Open
    s.Write x.responseBody
    s.SaveToFile fileName
    s.Close
   
    Set x = Nothing
    Set s = Nothing
  End Sub
Private Sub Command0_Click()
    SaveWebPicture "http://cimg2.163.com/mobile/2008/3/18/160_129.jpg", "D:\Test.jpg"
End Sub

提示
Dim x As New XMLHTTP
    Dim s As New ADODB.Stream
错误


怎么引用XML啊?
作者: tmtony    时间: 2008-3-19 17:38
在工具 引用 里引用 Mircosoft XML 6.0 或其它版本
作者: sunwrsun    时间: 2017-6-30 10:16
看看
作者: wuwu200222    时间: 2020-11-24 09:52
学习




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3