<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title></title>
</head>

<body>
<pre>


○○○Sub autoInput()
    
    Dim strURL: strURL = "https://ukiuki.in/"
    Dim objShell, objWindow
    Dim objIE

    Set objShell = CreateObject("Shell.Application")

    Set objIE = Nothing
    For Each objWindow In objShell.Windows
        If TypeName(objWindow.document) = "HTMLDocument" Then
           If Left(objWindow.document.URL, 18) = strURL Then
               Set objIE = objWindow
               Exit For
           End If
        End If
    Next
    Set objShell = Nothing

    If objIE Is Nothing Then
        strWeb = "https://ukiuki.in/ukiuki/kakeibo/kakeiInput.html"
        Set objIE = CreateObject("InternetExplorer.Application")
        objIE.Navigate strWeb
        
        'IEの表示完了を待つ
        While objIE.ReadyState <> 4 Or objIE.Busy = True
           Application.wait Now() + TimeValue("00:00:03")
        Wend
        
        'MsgBox "指定のサイトがありません"
        'WScript.Quit
        
    End If

    Dim MaxRow As Integer: MaxRow = Cells(Rows.Count, 1).End(xlUp).Row
    For Row = 1 To MaxRow
        
        date1 = Cells(Row, 1).Text '日付
        ctype = Cells(Row, 2) '収支
        categoryID = Cells(Row, 3) '項目
        
        amount = Cells(Row, 5) '金額
        Product = Cells(Row, 6) '商品名
        
        accountID = Cells(Row, 10) '収支口座
        
        If ctype = "支出" Then
            'MsgBox date1 & crlf & accountID & crlf & categoryID & crlf & subcategoryID & crlf & Product & crlf & amount
            Call autoSet(objIE, date1, accountID, categoryID, subcategoryID, Product, amount)
        End If
        
    Next
    MsgBox "ok"
End Sub

Sub autoSet(ByVal objIE, ByVal date1, ByVal accountID, ByVal categoryID, ByVal subcategoryID, ByVal Product, ByVal amount)
    
    Call setValue(objIE, "date", date1)

    Call setectItem(objIE, "accountID", accountID)

    Call setectItem(objIE, "categoryID", categoryID)
    Call setectItem(objIE, "subcategoryID", subcategoryID)

    Call setValue(objIE, "product", Product)
    Call setValue(objIE, "shop", "")
    Call setValue(objIE, "amount", amount)

    Call Click(objIE, "doUpdate")
    Application.wait Now() + TimeValue("00:00:01")
    
End Sub

Sub setectItem(ByVal objIE, ByVal id, ByVal Val)
    'objIE.document.all("pref")(2).Selected = True
    If Val = "" Then
        Exit Sub
    End If
    Dim elms
    Set elms = objIE.document.getElementById(id)
    For i = 0 To elms.Length
        If elms(i).Text = Val Then
            elms(i).Selected = True
            elms.fireEvent ("onchange")
            Exit For
        End If
    Next
End Sub

Sub setValue(ByVal objIE, ByVal id, ByVal Val)
    Dim elms
    Set elms = objIE.document.getElementById(id)
    elms.Value = Val
End Sub

Sub Click(ByVal objIE, ByVal id)
    Dim elms
    Set elms = objIE.document.getElementById(id)
    elms.Click
End Sub



</pre>
</body>
