Created
December 7, 2015 10:23
-
-
Save cw-oide/3141e384bbc6e7d2014b to your computer and use it in GitHub Desktop.
追加するメンバーをIDを指定して追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub メンバー追加(addMemberID) | |
bottomRow = Worksheets("チャットワークRoom").Cells(1, 1).End(xlDown).Row | |
For i = 1 To bottomRow | |
roomID = Worksheets("チャットワークRoom").Cells(i, 1).Value | |
myURL = "https://api.chatwork.com/v1/rooms/" & roomID & "/members" | |
memberList = Worksheets("チャットワークRoom").Cells(i, 3).Value | |
tmpList = Split(memberList, "-") | |
If IsNull(tmpList(1)) = False Then | |
If InStr(tmpList(1), addMemberID) = 0 Then | |
If InStr(tmpList(1), "members_member_ids") <> 0 Then | |
tmpList(1) = tmpList(1) & "," & addMemberID | |
Else | |
tmpList(1) = "members_member_ids=" & addMemberID | |
End If | |
End If | |
End If | |
memberList = tmpList(0) & "-" & tmpList(1) | |
If InStr(memberList, "admin") <> 0 Then | |
myPostData = Replace(memberList, "-", "&") | |
Set myHttpRequest = CreateObject("MSXML2.XMLHTTP.3.0") | |
Call myHttpRequest.Open("PUT", myURL, False) | |
Call myHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") | |
Call myHttpRequest.setRequestHeader("X-ChatWorkToken", Token) | |
Call myHttpRequest.send(myPostData) | |
Result = myHttpRequest.responseText | |
Set myHttpRequest = Nothing | |
Else | |
Next i | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment