Excel VBA,填写互联网,每个来自不同的URL [关闭]

问题描述 投票:-2回答:1

我想在互联网上填写一个表单,每个表单都有自己的url,它保存在excel单元格中,并且这个特定表单的所有数据都是相同的原始数据,所以我想运行一个循环单循环来输入数据,它很不错对于第一个原始,当它转到下一个我,给了我错误91,为

IE.Navigate (url_name)

所以不知道如何把它作为变量:我需要尽快帮助

这是代码

Sub FileInternetForm()

Dim IE As Object   
Set IE = CreateObject("InternetExplorer.Application")

'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title ba

Dim i As Integer

For i = 1 To 100  
    '''Go to page

    Dim url_name As String

    url_name = ActiveSheet.Cells(i, 1)

    If url_name = "" Then Exit Sub

    ''With url_name

    IE.Navigate (url_name)

    'go to web page listed inside quotes

    IE.Visible = True        

    While IE.busy    
        DoEvents 'wait until IE is done loading page.    
    Wend    
    ''End With

    '''''' start

    Set tbcno = IE.document.getElementById("tbcno")    
    tbcno.Value = ActiveSheet.Cells(i, 2)

    Set Name = IE.document.getElementById("name")    
    Name.Value = ActiveSheet.Cells(i, 3)

    Set Email = IE.document.getElementById("email")    
    Email.Value = ActiveSheet.Cells(i, 4)

    Set mobile = IE.document.getElementById("mobile")    
    mobile.Value = ActiveSheet.Cells(i, 5)

    Set gender = IE.document.getElementById("gender")    
    gender.Value = ActiveSheet.Cells(i, 6)

    Set licenseno = IE.document.getElementById("licenseno")    
    licenseno.Value = ActiveSheet.Cells(i, 7)

    Set girno = IE.document.getElementById("girno")    
    girno.Value = ActiveSheet.Cells(i, 8)

    Set panno = IE.document.getElementById("panno")    
    panno.Value = ActiveSheet.Cells(i, 9)

    Set haddress = IE.document.getElementById("haddress")    
    haddress.Value = ActiveSheet.Cells(i, 10)            

    Set hcity = IE.document.getElementById("hcity")    
    hcity.Value = ActiveSheet.Cells(i, 11)

    Set hpin = IE.document.getElementById("hpin")    
    hpin.Value = ActiveSheet.Cells(i, 12)

    Set hstate = IE.document.getElementById("hstate")    
    hstate.Value = ActiveSheet.Cells(i, 13)

    Set oaddress = IE.document.getElementById("oaddress")    
    oaddress.Value = ActiveSheet.Cells(i, 14)            

    Set ocity = IE.document.getElementById("ocity")    
    ocity.Value = ActiveSheet.Cells(i, 15)

    Set opin = IE.document.getElementById("opin")    
    opin.Value = ActiveSheet.Cells(i, 16)

    Set lal = IE.document.getElementById("lal")    
    lal.Value = ActiveSheet.Cells(i, 17)            

    Set mrnno = IE.document.getElementById("mrnno")    
    mrnno.Value = ActiveSheet.Cells(i, 18)

    Set af = IE.document.getElementById("af")    
    af.Value = ActiveSheet.Cells(i, 19)

    Set nri = IE.document.getElementById("nri")    
    nri.Value = ActiveSheet.Cells(i, 20)

    Set cp = IE.document.getElementById("cp")    
    cp.Value = ActiveSheet.Cells(i, 21)

    'Click Button '                
    IE.document.getElementsByClassName("btn btn-info btn-fill")(0).Click

    ''Close Ie                
    IE.Quit

    Set IE = Nothing

Next i

End Sub
excel vba web
1个回答
1
投票

艾哈迈德,你正在关闭循环内的IE浏览器。

热门问题
推荐问题
最新问题