Function FormElements(strHtmText)
'Returns a dictionary of form "input" elements and their default values
'For example, with HTML text containing this:
'
'A declaration might be like this:
'Set dicForm = FormElements(strHtmText)
'With data testing like this:
'If dicForm.Exists("wpSection") Then MsgBox dicForm("wpSection")
Dim arrInputs, strInputs, strInput, intCount, strName, strValue, dic
Set dic = CreateObject("Scripting.Dictionary")
strInputs = strHtmText
strInputs= Replace(strInputs, ""))
strName = ""
If InStr(1, strInput, " name=", vbTextCompare) <> 0 Then
strName = Mid(strInput, InStr(1, strInput, " name=", vbTextCompare))
strName = Mid(strName, InStr(strName, "=") + 1)
Select Case Left(strName, 1)
Case """"
strName = Split(strName, """")(1)
Case "'"
strName = Split(strName, "'")(1)
Case Else
strName = Split(strName, " ")(0)
End Select
End If
strValue = ""
If InStr(1, strInput, " value=", vbTextCompare) <> 0 Then
strValue = Mid(strInput, InStr(1, strInput, " value=", vbTextCompare))
strValue = Mid(strValue, InStr(strValue, "=") + 1)
Select Case Left(strValue, 1)
Case """"
strValue = Split(strValue, """")(1)
Case "'"
strValue = Split(strValue, "'")(1)
Case Else
strValue = Split(strValue, " ")(0)
End Select
End If
If strName <> "" Then
dic.Add strName, strValue
End If
Next
Set FormElements = dic
Set dic = Nothing
End Function