Add Keys to a collection of For Each statement
Mac対応にあたりDictionaryオブジェクトを「Microsoft Scripting Runtime」の代わりに、VBA-tools/VBA-Dictionary を使用した場合、WebDriver.clsのFor Eachの部分で「実行時エラー 438 オブジェクトは、このプロパティまたはメソッドをサポートしていません」が出ます。
' Run-time error '438': Object doesn't support this property or method
For Each paramKey In parameters
For Each key In dict
Keysを追加して頂ければ、このエラーは回避することが出来ます。
For Each paramKey In parameters.Keys
For Each key In dict.Keys
Keysを付けた状態で、Windows上で「Microsoft Scripting Runtime」を参照していてもエラーにならずに正常動作します。
Hi @yaju , thank you for reporting issue.
Sounds great. I'm so excited about resolving this issue makes it compatible with Mac!
Hi @yaju ,
I found that to make this run on Mac, we have to replace WebDriver.SendRequest() method that uses CreateObject("MSXML2.ServerXMLHTTP") internally.
Do you have any idea?
Mac対応するにあたり、内部的に CreateObject("MSXML2.ServerXMLHTTP") をしている WebDriver.SendRequest() を改修する必要があるとわかりました。curlを利用するなどいくつかの方法があるようですが、他に良い方法をご存知でしょうか?
@uezo
自分のところでは、既にMacでExampleのyomoda sobaは動いています。近いうちに記事を書く予定です。 CreateObject("MSXML2.ServerXMLHTTP") の代わりにVBA-Webを使用していますが、その中身ではcurlを利用しています。 また、MacでShellが動作しない件については既に記事を書いてあります。 出来るか分かりませんが、最終的にはVBA-Webを使わない方向にしたいです。
' Send HTTP request
Private Function SendRequest(method As String, url As String, Optional Data As Dictionary = Nothing) As Dictionary
Dim client As Object
Dim Response As WebResponse
Set client = New WebClient
If method = "POST" Or method = "PUT" Then
Set Response = client.PostJson(url, Data)
Else
Set Response = client.GetJson(url)
End If
Dim json As Object
Set json = JsonConverter.ParseJson(Response.Content)
Set SendRequest = json
End Function
Hi @yaju , It's looking good to me, thank you so much! I don't think much users want to do web scraping with VBA as you said, however, this will help me to develop features on my Mac.