Get web data for VBA string

Asked

Viewed 37 times

0

Good morning! I developed some macros and functions for my use in the company and I would like to validate their use by searching a web page. the page is actually a blogspot. in which I will leave a post with a text only.

type. if you have such content on the web run the macro, otherwise do not execute.

would be like a lock for unwanted macro users.

the problem is that I can’t find information on how to do this web check. anyone would have any suggestions? material where I can find!

  • The location where this text is located will need some validation, such as user, password, cookies and/or token, or is a simple HTML request?

  • @Césarrodriguez is a simple request, I put an example on link

1 answer

2

built in my form the following code

 Private Sub UserForm_Activate()
  Dim validacao, retorno As Variant
  Dim site As Object
  Set site = CreateObject("WinHttp.WinHttpRequest.5.1")
  On Error GoTo proximo
  site.Open "GET", "https://jsrconfig.blogspot.com/"
  site.Send
  validacao = site.responsetext
  retorno = InStr(1, validacao, "habilitados", vbTextCompare)
  If retorno = 0 Then
    MsgBox ("As macros foram dasabilitadas pelo criador!!")
    For Each item In ThisWorkbook.VBProject.VBComponents
      ThisWorkbook.VBProject.VBComponents.Remove item
    Next item
   Unload MENU
 End If
proximo:

if there is a simpler form accept suggestions

  • That’s right. I didn’t answer because I’m traveling in a place with restricted Internet access.

  • 1

    @Césarrodriguez thanks for the return!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.