form0.htmlファイルのタグ例 |
<FORM NAME="Myfm"> text(1)<IINPUT TYPE="text" NAME="txt1" SIZE=30 MAXLENGTH=20><br><br> text(2)<IINPUT TYPE="text" NAME="txt2" SIZE=30 MAXLENGTH=20><br><br> text(3)<IINPUT TYPE="text" NAME="txt3" SIZE=30 MAXLENGTH=20><br><br> </FORM> <FORM > text(3)<INPUT TYPE="text" NAME="txt4" SIZE=30 MAXLENGTH=20>&<br><br> text(4)<IINPUT TYPE="text" SIZE=30 MAXLENGTH=20><br><br> </FORM> |
Private Declare Function SetForegroundWindow Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function IsIconic Lib "user32" _ (ByVal hWnd As Long) As Long Private Declare Function ShowWindowAsync Lib "user32" _ (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Dim myobj As Object, objIE As Object Dim fff As String, mycnt As Variant Dim sanp As Integer -------------------------------------------------------- Sub form1() fff = ThisWorkbook.Path & "\form01.html" sanp = 1 Call form End Sub |
PSub form() Set myobj = CreateObject("Shell.Application") mycnt = myobj.Windows.Count fff = "http://www2s.biglobe.ne.jp/~iryo/" With myobj.Windows Shell ("EXPLORER.EXE " & fff) Do DoEvents Loop Until mycnt + 1 <= .Count Set objIE = .Item(mycnt) End With Do While objIE.ReadyState <> 4 Or objIE.Busy = True DoEvents Loop Select Case sanp Case 1 Call form1a Case 2 Call form2a End Select If IsIconic(objIE.hWnd) Then ShowWindowAsync objIE.hWnd, &H9 End If SetForegroundWindow (objIE.hWnd) Set objIE = Nothing Set myobj = Nothing End Sub ------------------------------------------------------- Sub form1a() With objIE.Document .all("txt1").Value = "text(1)へ記入 12345" .all.txt2.Value = "text(2)へ記入 abcde" .Myfm.txt3.Value = "text(3)へ記入 ABCDE" .getElementById("txt4").Value = "text(4)へ記入 あいうえお" .forms(1).elements(1).Value = "text(5)へ記入 67890" End With End Sub |
Sub form2a() With objIE.Document .all.bu1.Click .forms(1).elements(0).Click End With End Sub |
Sub form3a() objIE.Document.forms(0).razio(2).Click Rem objIE.Document.forms(0).elements(2).Click End Sub |
Sub form4a() objIE.Document.Myfm.chk4.Checked = True Rem objIE.Document.Myfm.elements(3).Checked = True End Sub |
Sub form5a() objIE.Document.Myfm1.Myop.selectedIndex = 2 End Sub |
Sub form6a() With objIE.Document.frames("fm2").Document .all("txt1").Value = "フレーム2へ書き込みテスト(1)" .all("txt2").Value = "フレーム2へ書き込みテスト(2)" .Myfm.txt3.Value = "フレーム2へ書き込みテスト(3)" .all("txt4").Value = "フレーム2へ書き込みテスト(4)" .forms(1).elements(1).Value = "フレーム2へ書き込(5)" End With End Sub |
forms(0).elements(0) ⇒ forms(0).elements(1) ⇒ forms(0).elements(2) ⇒ forms(1).elements(0) ⇒ forms(1).elements(1) ⇒ |