Beranda > Pemrograman > Autofill Form IE Menggunakan MS Excel VBA

Autofill Form IE Menggunakan MS Excel VBA

Tutorial kali ini akan membahas bagaimana mengisi form pada Internet Explorer (IE) menggunakan MS Excel VBA.

Sumber : http://www.excely.com/excel-vba/ie-automation.shtml

Dalam contoh dibawah ini saya menggunakan sebuah file htm yang ditempatkan dalam drive C.

Berikut source code file tersebut :

nama textbox = q : <input id=”f1″ type=”text” name=”q” size=”69″ maxlength=”250″ accesskey=”S” /> <br>
<br>
nama textbox = r : <input id=”f1″ type=”text” name=”r” size=”69″ maxlength=”250″ accesskey=”S” /><br>
<br>
nama textbox = s : <input id=”f1″ type=”text” name=”s” size=”69″ maxlength=”250″ accesskey=”S” /><br>
<br>

Masuk kedalam Visual Basic Editor. Setelah itu buat sebuah form yang berisi sebuah Textbox dan sebuah Command Button. Seperti terlihat pada gambar dibawah ini :

Selanjutnya masuk ke code editor dan copy kan kode dibawah ini :

Private Sub IE_Autiomation()
Dim i As Long
Dim IE As Object
Dim objElement As Object
Dim objCollection As Object
Set IE = CreateObject(“InternetExplorer.Application”)
IE.Visible = True
IE.navigate TextBox1
Application.StatusBar = TextBox1.Text & ” is loading. Please wait…”
Do While IE.Busy
Application.Wait DateAdd(“s”, 1, Now)
Loop
Application.StatusBar = “Search form submission. Please wait…”
Set objCollection = IE.document.getElementsByTagName(“input”)
i = 0
While i < objCollection.Length
If objCollection(i).Name = “q” Then
objCollection(i).Value = “MENCOBA”
End If
If objCollection(i).Name = “r” Then
objCollection(i).Value = “AUTO FILL FORM IE”
End If
If objCollection(i).Name = “s” Then
objCollection(i).Value = “MENGGUNAKAN EXCEL VBA”
End If

If objCollection(i).Type = “submit” And _
objCollection(i).Name = “” Then

Set objElement = objCollection(i)

End If

i = i + 1
Wend

Do While IE.Busy
Application.Wait DateAdd(“s”, 1, Now)
Loop

IE.Visible = True

Set IE = Nothing
Set objElement = Nothing
Set objCollection = Nothing

Application.StatusBar = “”
End Sub

Private Sub CommandButton1_Click()
IE_Autiomation
End Sub

Kategori:Pemrograman
  1. 4 September 2014 pukul 2:47 pm

    My brother recommended I might like this blog. He was entirely right.
    This publish actually made my day. You cann’t imagine simply how so much time I had spent for this
    info! Thank you!

  2. 3 Oktober 2014 pukul 12:15 pm

    My family members all the tim say that I am wasting my tim here at net, however I know I
    am getting familiarity dail by reading thes pleasant articles
    or reviews.

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: