- Make sure that the object that you're trying to use is not properly set
- Validate its related references are added properly in VBA references
- Implement VBA exception handling to get more detailed info
Can We Use MS Graph API in MS Project VBA
Hello.,
i have just created a simple app in vb.net to create planner Task using MS Graph API and Its working fine.
i am thing now its very easy to me ,if i use the above code in MS Project VBA instead of VB.net.
can anyone help me, how to use MS Graph API in MS Project VBA.
i have used the code mention in the below link
how-to-call-microsoft-graph-api-using-vba
but i am getting error in below coding:
GetToken = doc.getElementsByName("access_token")(0).Value
error detail is:
Run time error '91'
Object variable or With Block variable not set
Please help me to resolve this
TJTalha
3 answers
Sort by: Most helpful
-
Deva-MSFT 2,261 Reputation points Microsoft Employee
2021-01-15T19:00:51.877+00:00 -
TJTalha 1 Reputation point
2021-01-18T10:19:20.397+00:00 @Deva-MSFT thanks for your replay.
i have used below code to get cleint secret.
Function GetToken() Dim xml As New MSXML2.XMLHTTP60 Dim doc As MSHTML.HTMLDocument Dim urltoken As String 'copy paste the URL you see when calling Microsoft Graph Explorer and add prompt + domain_hint parameters urltoken = "https://login.microsoftonline.com/XXXXXXXXXXXXXX/oauth2/v2.0/token" xml.Open "GET", urltoken, False xml.send ("client_id=XXXXXXXXXXXXXX&scope=https://graph.microsoft.com/.default&grant_type=client_credentials&client_secret=(cleint secret}") If xml.readyState = 4 And xml.Status = 200 Then Set doc = New MSHTML.HTMLDocument doc.Body.innerHTML = xml.responseText GetToken = doc.getElementsByName("access_token")(0).Value sSuccess = True Else MsgBox "Error" & vbNewLine & "Ready state: " & xml.readyState & _ vbNewLine & "HTTP request status: " & xml.Status sSuccess = False End If Set xml = Nothing End Function
also i have added reference "MSXML v6.0" .
Is any think needed to change please help me.
TJTalha -
Jose Roberto Oliveira 0 Reputation points
2023-04-04T00:30:07+00:00 Any updates on this? I'm struggling with the same error. :(