folks,
i can successfully reach a web page from a UserForm within an Excel workbook and retrieve a website print image using .Navigate; i can even switch to a second web page and retrieve a website print image. but i get a 'script' error, either as i retrieve the first webpage, or as i retrieve the second web page. if i click 'yes' to continue running the script, it proceeds without issue. i don't have sufficient 'debug' experience to follow what is throwing the error. so, if you can help me find the 'root cause', maybe i can fix the error?
this attachment is the error message
the navigate module is here:
Private Sub optCandleChart_Change()
Me.wbSCC.Navigate "http://stockcharts.com/h-sc/ui?s=" & txtTicker1.Value & "&p=D&b=5&g=0&id=t56926565868&r=1501858722627&cmd=print"
End Sub
when the UserForm launches, a ticker is fed from the Excel worksheet to the UserForm in txtTicker1.Value. it works, just hitting 'Yes' to continue running script is a bit tacky. is it because i am not setting up 'Change()' properly?
thanks,
ron
Related
I am new in VBA and Selenium. Wrote some lines using Selenium ChromeDriver that can open a online data management system, and log in successfully. I need to manually click on a map, and a table pops up where I need to input some data from a excel sheet using VBA. On that online page, I can access all the components using various methods (e.g., FindElementByName, FindElementByXPath, etc.) **except **the edit boxes and the dropdown elements on the popup table. I even can access the buttons on the bottom of the table. Only when I try to access the elements on the table, it give me the RUN TIME ERROR 7 OUT OF MEMORY. I have attached an image but hid some elements due to the confidential nature of the work. I know it is not a lot of information, but if someone can give me some directions I will highly appreciate it.
Thanks
I am using Selenium Chrome Driver
'Other Subs are here....
Sub Entry()
'I am using these methods to test
myChrome.FindElementByXPath("//div[#class='ui-jqgrid-bdiv']//input[#name='input_ROUTE']").Value = "500"
myChrome.FindElementByName("input_ROUTE").SendKeys "500"
'These throws the Run-time error 7, Out of memory
'However, the same methods works for everything else except the elements on that table
End Sub`
Check the HTML, it is possible that input_ROUTE is inside an iframe element, and the XPath you get is internal inside the iframe.
If this is the case, you need to first move into the iframe and then turn to the internal component. so:
myChrome.SwitchToFrame myChrome.FindElementByXPath("//*[#id=""loginIframe""]") 'Of course you need to change the XPath
myChrome.FindElementByName("input_ROUTE").SendKeys "500"
I'm trying to submit a form but every time I hit the submit button instead of submitting the data it just straight refreshes the page.
I was originally able to get it to work by doing:
doc.getElementByTagName("button")(1).Click
but it stopped working a couple of weeks ago which makes me think something on the website changed.
I've since tried using a queryselector & also just submitting the form using form.submit but get the same result of not submitting any data & just refreshing the page.
The line of code that submits is:
<button data-testid="submit-eligibility" class="rds-primary-button is-white-labeled-btn eligibility-lookup__PartnerButton-sc-13jrfc8-1 dDEqAx">Submit</button>
I also can't use selenium because it is on a work computer & I am unable to download or install anything without admin privileges.
Any help would be greatly appreciated.
Thanks!
This is the website that I've been trying to submit the form:
https://www.partneroptumfitness.com/
I use sendkeys to input the values from excel & that code still works but I can't even get an error saying that this field needs to be filled out before submitting which is what it normally does but doesn't even show that any longer.
I'm trying to submit the second form on the page.
I am currently creating an automation to fill-in field in the browser (Chrome) with VBA and selenium. Which is currently doing fine. (the site is internal)
However, I came across with this "message from web" prompt after saving / submitting the information. Sometimes, this pop-up box gives me a prompt that it was saved successfully and sometimes, if there are errors, the message box contains some text.
In order for me to handle this pop-up message box and put some validation. In this case, I would like to get the text inside this message box. (Please refer to the red arrow).
The code below is what I used in order to accept / click the "OK" button. And doesn't have any problems. However, as mentioned, I would like to get the text inside that box to put some validation.
What I tried so far:
driver.SwitchToAlert
driver.SwitchToAlert.Text <<<--- this is where I attempt to get the text however, it doesn't work.
driver.SwitchToAlert(20).accept
Also, I have check below code:
driver.switchTo().alert().getText();
However, this seems not to be working in VBA / selenium.
Try such a code (Change to suit your issue)
Dim bot As Selenium.ChromeDriver
Sub Test()
Dim dlg As Selenium.Alert
Set bot = New Selenium.ChromeDriver
With bot
.Get "http://the-internet.herokuapp.com/javascript_alerts"
.FindElementByCss("#content > div > ul > li:nth-child(2) > button").Click
Set dlg = .SwitchToAlert(Raise:=False)
Debug.Print dlg.Text
.Wait 2000
dlg.Dismiss
End With
End Sub
I want to use the BeforePrint event in Excel in order to edit the header and footer of the final printout depending on various parameters. In order for the user to check whether the page setup is right, this code needs to be called before the print preview within Excel is shown. When calling the print preview with the VBA code ThisWorkbook.PrintPreview, the event fires before the preview is shown, but when using "Ctrl+P" or "File - print" the event is not called until the document is sent to the printer, so the print preview does not show the final printout. The code Application.CommandBars.ExecuteMso "PrintPreviewAndPrint" also leads to the same unsatisfying result.
I've noticed, that when using ThisWorkbook.PrintPreview the preview is shown in full screen mode while the other methods show the 'normal' print preview. To test if the event is called, I used the following short piece of code.
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Debug.Print "BeforePrint"
End Sub
I need a foolproof way of showing the correct print preview, so using a button with the VBA code mentioned above is no option. Any suggestions?
Thanks in advance, mk
Even though you have not disclosed which Excel version you are using (it might be vital in this case). I am afraid that getting .BeforePrint event called before the Printing preview when using Ctrl+P might not be possible in your case since "Excel 2013 and later doesn't run Workbook_BeforePrint on Print Preview." (user OzRoz, 2017)
The above answer is taken from a thread which was asking similar question. In the answer, OzRoz also mentions that "you can get it to run for testing by adding the 'Print Preview Full Screen' icon to your QAT (Quick Access Toolbar)"
Perhaps this provides a definitive answer to your problem.
So I have been able to load a PDF into my userform (Excel 2013 on all machines) setting reference Adobe Acrobat Webrowser Control and adding control to userform. When i open the file on another computer or try to create another excel userform and pdf I get the following errors "Run-time error-459" or "Element not found" or "Compile error: Method or data member not found"
I am using Acrobat Adobe Reader DC
I also noticed when adding control to form it labels it as Control1 instead of AcroPDF1
Private Sub Workbook_Open()
With UserForm1.Control1
.LoadFile ThisWorkbook.Path & "\sample.pdf"
End With
UserForm1.Show
End Sub
Please any help much appreciated
Make sure that the Additional Control for Adobe has been added. Also take a quick look into this post for workaround and suggestions. http://www.ozgrid.com/forum/showthread.php?t=88177
After some trial and error i found a solution. I was currently using google chrome when experiencing this issue. The problem was that i had a google app conflicting with the pdf. So i disabled google apps and problem dissappeared. Sorry comunity i didnt resopnd earlier..thanks for all the input