我需要有关此主题的帮助。
图片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浏览器中显示图像。
提前感谢您的帮助。
答案 0 :(得分:1)
在模块顶部声明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
在表单上使用Image Control并将其命名为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