Handle Google Chrome with VBA

Asked

Viewed 24,244 times

-1

I’m creating a code that enters my company’s online system, but it can only be accessed by Google Chrome.

The code to open Chrome is this:

Sub Chrome()

    Dim GC As Object
    Dim WebUrl As String
    Dim NavigatorAddress As String

    Let NavigatorAddress = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
    Set GC = CreateObject("InternetExplorer.Application")
    Let WebUrl = "http://endereço/do/sistema"

    Shell (NavigatorAddress & " -url " & WebUrl)

    GC.Document.all("vUSU_CODIGO").innerText = "login"
    GC.Document.all("vSENHA").innerText = "sennha"

    GC.Document.all("vUSU_CODIGO").form.all("BUTTON1").Click

End Sub

The code opens Chrome on the right link and everything, but I can’t fill in the login or password.

  • No browser lets itself be manipulated as you want, for security reasons. If this were possible, there would be no operating system update or anti-malware that would account for all forms of attack that this would enable.

  • Puts, it’s understandable. Thank you.

  • Man use some vbs and Sendkeys that you can fill in user and password easily without using Selenium neither python nor anything vbs is like VBA a quick search by vbs sendkey and vc find what you need

2 answers

0

I know this Post is old, but there is a logic error in it. The GC object refers only to the Internet Explorer object created by the Create command. Navigatoraddress and Weburl refer to Google Chrome. But at no time is there a connection between and Internet Explorer. Therefore, Chrome is opened normally. While there is also the attempt to pass the user and password to Internet Explorer. As the Nerd Laser said, there is, in this case, the possibility to use SENDKEYS (which is also present in VBA). There is also a program called Autoit.

-2

Yes, it is possible (there are times!) to automate procedures in browsers. In your case, the only component that exposes objects, properties and methods is Internet Explorer (a quick search for "Internetexplorer.Application" already brings the exact results with the full explanation on the subject, direct from MS). The others can be automated with the use of other libraries, such as Selenium Webdriver (https://www.tomasvasquez.com.br/blog/microsoft-office/excel/vba-interagindo-com-paginas-web-com-o-selenium-webdriver). Good luck!

  • This link may be a good suggestion, but your reply will not be valid if one day the link crashes. In addition, it is important for the community to have content right here on the site. It would be better to include more details in your response. A summary of the content of the link would be helpful enough! Learn more about it in this item of our Community FAQ: We want answers that contain only links?

Browser other questions tagged

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