Skip to content

Instantly share code, notes, and snippets.

@aki-lua87
Last active August 5, 2018 14:35
Show Gist options
  • Save aki-lua87/18926797f3958665f592 to your computer and use it in GitHub Desktop.
Save aki-lua87/18926797f3958665f592 to your computer and use it in GitHub Desktop.
ExcelにTwitterのつぶやきを表示してみた ref: https://qiita.com/aki_lua87/items/f973f11f413d7d73a2bd
echo $str."を検索します \n";
//文字化け対策
ob_start(function($buf){ return mb_convert_encoding($buf, 'SJIS', 'UTF-8'); });
//出力
foreach($result->statuses as $status):
echo $header;
echo $status->text;
echo $footer;
echo "\n";
endforeach;
echo "end";
?>
Sub ExcelでTwitterする()
Dim path As String
Dim query As String
Dim i As Integer
Dim WSH, Exec_cmd, Com As String 'コマンドライン用
Dim Result, tmph() As String '結果入れ
path = ThisWorkbook.path 'このファイルのパス
query = Range("H3") 'H3セルに検索語句を入れておく
'コマンドプロンプトオブジェクト
Set WSH = CreateObject("WScript.Shell")
'コマンド生成
Com = "php " & path & "\excel_de_twitter.php"
'コマンド実行
Set Exec_cmd = WSH.Exec("%ComSpec% /c " & Com)
'検索語句を標準入力に
Exec_cmd.StdIn.WriteLine (query)
Do While Exec_cmd.Status = 0
DoEvents '終わるまで待つ
Loop
'結果をすべて格納
Result = Exec_cmd.StdOut.ReadAll
'ヘッダーで分離
tmph = Split(Result, " he@@der ")
'フッターで分離->L列にどんどんん入れる
For i = 1 To UBound(tmph)
Cells(i + 1, 12) = Split(tmph(i), " f@@ter")
Next i
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment