I am automating a web process with VBA. I go find an object on a webpage using
IE.document.getelementsbytagname
etc.. Once that object is found, you can single click using
objElement.click
The question is, how do I double click?? All my searches have come up with nothing. I thought dblClick or doubleClick would do the trick, but those are invalid methods. I tried a workaround by using
objElement.click
sendkeys "{ENTER}"
to click and then hitting enter would open the link, but that doesn't work either.
I finally got this working:
objElement.click
objElement.FireEvent "ondblclick", 1, 2
Related
I would ask you a question. I just now figured out this. In vba selenium if a website loaded fully but you cant see whole site so you need to scroll down to see whole site. vba is applying code if you cant see that class ,id or whatever parameter you are using in your code until you see that thing on your window. let me explain more clear.
i opened a website with vba selenium chromedriver. vba should click a button after filling up form.
if after website fully loaded and button is not visible at first site loaded and i need to scroll down to see the button, button.click will not work. if i scroll down and see button and then only button.click will work.
if i change zoom with
driver.ExecuteScript "document.body.style.zoom='50%';"
then not any click command is working.
anybody has any idea how to do that?
the thing im trying to do; when site loaded captcha is coming. and im giving to user 10 sec to solve captcha. and then automate will click login. if i scroll down to see login button its fine working. if i dont scroll down to see login button code it not working.
next pages im taking from site all links which i want to click with this code;
For Each site In sites
Debug.Print site.Attribute("href")
site.Click ("href")
sayfa.Wait 10000
sayfa.SwitchToNextWindow
sayfa.Window.Close
sayfa.SwitchToPreviousWindow
Next site
it was always giving error. finally i figured out it. if i can see on website without scroll down or up that link which i will click, its working. but if i cant see link code is not working.
i became crazy :)
i will be appreciate if anybody can help.
solved. i added
Site.ScrollIntoView True
If Site.IsDisplayed Then
driver.Wait 10000
Site.ScrollIntoView True
Site.Click ("href")
driver.Wait 20000
driver.SwitchToNextWindow
driver.Window.Close
driver.SwitchToPreviousWindow
Else
End If
Next Adres
I have created a button in a excel sheet that opens the Find menu (ctrl+f).
Sub Button6_Click()
Application.Dialogs(xlDialogFormulaFind).Show
End Sub
After the search is done and one closes this menu excel doesn't respond anymore and closes itself. Any ideas why?
Also, I don't get the exact same find dialog as when I use ctrl+f. Is there maybe a way to use keyboard-functions in vba?
Why not use ctrl+f instead of the button. Because my colleagues are not quite good with excel and that already is too much to remember for them :)
This is how to mimic a key press in VBA ^ is Ctrl
Sub Button6_Click()
Application.SendKeys ("^f")
End Sub
I tried recording opening the "Check Accessibility" option under the File>info>prepare for sharing, but nothing gets recorded. I have tried going through all of the Dialog show commands, but cannot find any that will open the menu.
I also tried to turn on the "Show Document Panel", and I can't get that to toggle either.
How can I have these open with the macro? I want to setup the workspace with a single button.
Try
Application.DisplayDocumentInformationPanel = True
Try this.
Application.CommandBars("Accessibility Checker").Visible = true
I have struck with one issue not finding any workable solution. Googled a lot without any success…HELP PLEASE.
Situation: Using MS Access 2010, there is one Form with WebBrowser Control (Unbound) for conducting some search, when I click the results of the search a Pop-up new Internet Explorer window opens for the search result.
Requirement: I need “new Internet Explorer window” needs to be opened on existing WebBrowser Control..... NOT to open separately as new pop-up Internet Explorer window.
Kindly provide me solution (MS Access 2010/VBA) or workaround….
Regards,
Sandy
Can you open the form that you are opening in the WebBrowser Control in a new browser window outside of the application in order to test something. Check to see, if when you open the url, and then invoke the search, if the results open in a new window for that browser. If so, then check the target of the form within the first screen to get the name of the window that the page is trying to open the results in. If the target is specified, then you will need to write code to remove it when the page loads.
Just assign the new web address to your webbrowser control. something like this. Note it has to include equal sign and a hyper-link surrounded by quote.
Private Sub WebBrowser34_Click()
Me.WebBrowser34.ControlSource = "='www.google.co.uk'"
End Sub
I am trying to use an excel add in in VBA. Unfortunately recording the macro doesn't seem to work and hence the reason I want to try use the keyboard shortcuts. The shortcut I am after is ALT X 2 V. I have tried using SendKeys.send ("%{x}{2}{v}")
but every time I try to use it, the code write the values "2v" to my vba screen. I am not sure I have fully understood how to use this method as I want the actions to be actioned in excel so that I can access this add in.
I have been through the forums but can't seem to get an answer, which includes putting a wait command between each keystroke. Could really do with some help.
Try SendKeys "%x2v"
That said, using sendkeys is almost always a Bad Idea. I understand that you're trying to call some function from an addin, but if you're able to access that code at all, I would do so, and call whatever you're trying to run directly. At some point, SendKeys will mess something up.