2
아래 VBA 코드는 파일에 대한 사용자 액세스 권한을 부여하기 위해 REST API를 호출합니다. REST API가 허용을 반환하면 코드가 정상적으로 닫히고 액세스 권한을 부여해야합니다. REST API가 다시 실행되지 않으면 프로그램에서 사용자와 통합 문서를 알려야합니다. 인터넷에 액세스 할 수없는 경우 사용자에게 알림을 보내고 책을 닫아야합니다.Excel VBA 매크로에서 REST API 처리 처리
제 질문은 어떻게 매크로를 올바르게 처리 할 수 있도록 REST API 응답을 처리하여 URL에서 응답을 허용하지 않으므로 정상적으로 종료 할 것인가? 여기
Private Sub Workbook_activate()
Application.EnableCancelKey = xlDisabled
' Run the Error handler "ErrHandler" when an error occurs.
On Error GoTo Errhandler
ActiveWorkbook.FollowHyperlink Address:="https://mysite.com/licensing/getstatus.php?", NewWindow:=True
' If response is allow
' Exit the macro so that the error handler is not executed.
****what goes here??****
Exit Sub
' If response is disallow
****what goes here??****
MsgBox "Your license key is not valid. Please check your key or contact customer service."
ActiveWorkbook.Close SaveChanges:=False
Errhandler:
' If no Internet Access, display a message and end the macro.
MsgBox "An error has occurred. You need Internet access to open the software."
ActiveWorkbook.Close SaveChanges:=False
End Sub
.FollowHyperlink() 메서드로 작업해야한다고 생각하지 않습니다. 아마도 웹 요청을 VBA 코드에서 분리 할 것이기 때문입니다. HttpWebRequest 및 HttpWebResponse 객체를 조사해보십시오 ... – Recipe