我有列,比如A列,包含1500行,每个行都有一个字符串(十六进制编码)。我需要的是连接到一个特定的网站搜索粘贴字符串,按下解码,复制结果并粘贴回B列。
任何帮助都会有很大帮助。我是新来的。
示例:
列A中的字符串:5468616e6b732061206c6f7420696e20616476616e6365
要搜索的网站:http://encodertool.com/hexadecimal
期待着一个答案。
谢谢你提前一百万。
发布于 2014-10-10 17:40:59
您这样做是为了使浏览器自动化吗?似乎您可以更容易地在VBA中直接完成它。
来自:http://bytes.com/topic/access/answers/874752-convert-hex-string
Sub tester()
Debug.Print fConvertHexToString( _
"5468616e6b732061206c6f7420696e20616476616e6365")
End Sub
Public Function fConvertHexToString(strHexString As String) As String
Dim intLenOfString As Integer
Dim intCounter As Integer
Dim strBuild As String
'Hex String must have a valid length, and it must be an even length
If Len(strHexString) = 0 Or Len(strHexString) Mod 2 <> 0 Then Exit Function
intLenOfString = Len(strHexString)
For intCounter = 1 To Len(strHexString)
If intCounter Mod 2 <> 0 Then 'need Hex pairs
'Retrieve the Value of the Hex Pair, then Convert to a Character,
'then Append to a Base String
strBuild = strBuild & Chr$(Val("&H" & Mid$(strHexString, intCounter, 2)))
End If
Next
fConvertHexToString = strBuild
End Function发布于 2014-10-10 10:06:06
就像这样。我刚运行了一个模拟测试,它很有效。试试看。您可以根据需要修改代码。这是一个普通的密码。代码也可以增强。但这符合你的要求
Dim ie As InternetExplorer
Dim doc As HTMLDocument
Sub start()
Dim ran As Range
Dim cel As Excel.Range
Set ran = Worksheets("Sheet1").Range("A1:A4") 'Change Your input range here
For Each cel In ran
If cel.Value <> Empty Then
Set ie = New InternetExplorerMedium 'open iE
ie.navigate ("http://encodertool.com/hexadecimal") 'Navigate to IE
ie.Visible = True
'Wait untill IE is loaded
Do
' Wait till the Browser is loaded
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
doc.getElementById("input_4").innerText = cel.Value ' Enter input value
test ' Click button
cel.Offset(0, 1).Value = doc.getElementById("output_4").innerText ' save Output value
End If
ie.Quit
Next cel
End Sub
'Click the Decode button
Sub test()
Set cl_button= doc.getElementsByTagName("a")
For Each one In cl_button
If one.getAttribute("onclick") = "ajaxfct('fcts.php','4')" Then
one.Click
Exit For
End If
Next one
End Sub在运行代码之前,添加对HTML对象库和Internet控件的引用。还可以更改输入的范围。我把它设为A1:A4。随便换吧。确保范围内没有空白单元格。ALso,如果您不想将浏览器设置为
ie.visible = false这是一种方法。THere是许多简单而有效的方法。
https://stackoverflow.com/questions/26294142
复制相似问题