从网页VBA(Excel)将图片传输到用户表单

我需要关于这个话题的帮助。

图像Html代码;

<IMG src="/SigortaliTescil/PG" width=50 height=25> 

我的VBA代码(Excel)

 Private Sub CommandButton3_Click() If TextBox1.Text = "" Then MsgBox "Lütfen Listeden Seçim Yapınız" Exit Sub End If Dim ie As Object Dim kontrol As String Set ie = CreateObject("internetexplorer.application") With ie .Navigate "https://uyg.sgk.gov.tr/SigortaliTescil/amp/loginldap" .Visible = True Set tags = ie.Document.getElementsByTagName("img") For Each tagx In tags If tagx.src = "/SigortaliTescil/PG" Then WebBrowser1.img = tagx.Doc End If Next 

如何在图片框或Web浏览器中显示图像。

预先感谢您的帮助。

在Module的顶部声明URLDownloadToFile函数:

 Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" (ByVal pCaller As Long, _ ByVal szURL As String, ByVal szFileName As String, _ ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long 

在表单上使用图像控件,并将其称为picBox。 然后在你的子更改为:

 Private Sub CommandButton3_Click() Const picURL = "https://uyg.sgk.gov.tr/SigortaliTescil/PG" Const dLoadPath = "C:\Desktop\downloadedPic.jpg" 'or whatever is appropriate 

....

 With ie .Navigate "https://uyg.sgk.gov.tr/SigortaliTescil/amp/loginldap" .Visible = True While ie.readyState <> READYSTATE_COMPLETE DoEvents Wend Set tags = ie.Document.getElementsByTagName("img") If tagx.src = picURL Then 'downloads to the dLoadPath filepath on the PC/Network - may wish to delete after?? Dim retVal as Variant retVal = URLDownloadToFile(0, picURL, dLoadPath, 0, 0) Me.picBox.Picture = LoadPicture(dLoadPath) Exit Sub End if