Selecting frame in Internet Explorer from Excel
I am trying to logon to a website from the Excel Macro, but cannot get it to
use the correct frame on the web page. There seems to be 2 main frames to the webpage, the login and password one, that I'm trying to use, and then the rest of the page. Below is the code I am using, I got it from another thread in the discussion group. Sub Open_Website() Set IExplorer = CreateObject("InternetExplorer.Application") IExplorer.Visible = True IExplorer.navigate "http://avotus/avotus/" Do While IExplorer.Busy And Not IExplorer.ReadyState = 4: Application.Wait (Now + TimeValue("0:00:02")) DoEvents Loop With Selection IExplorer.document.all("Login").Value = "sl704d" IExplorer.document.all("Password").Value = "******" IExplorer.document.forms(0).submit End With End Sub It opens the webpage perfectly, but gives me an error at the With Selection line. I have managed to save the HTML for just the login frame and I have run the macro successfully against this, so I'm thinking that it's not identifying the frames on the webpage right. My HTML programming is very limited, so that's maybe my biggest problem. Thank's in advance for any help. -- Cheers... |
Selecting frame in Internet Explorer from Excel
Hi Deke,
I'm not very clued up on navigating in IE, but have done some interesting digging and found the following link: http://www.dailydoseofexcel.com/arch...rnet-explorer/ If you're trying to target a specific frame then you might want to try looping through the frames to check the name of the one you're after: For x = 0 To IExplorer.Document.Frames.Length - 1 Debug.Print IExplorer.Document.Frames(x).Name Next x You could then target the correct frame with something like: IExplorer.Document.Frames("fraTarget").Document... ... Also, its worth stepping through your code (F8) as once you've got a reference to the document you can explore all of the elements via the Locals window. Anyway, hope that helps. Best regards John "Deke" wrote in message ... I am trying to logon to a website from the Excel Macro, but cannot get it to use the correct frame on the web page. There seems to be 2 main frames to the webpage, the login and password one, that I'm trying to use, and then the rest of the page. Below is the code I am using, I got it from another thread in the discussion group. Sub Open_Website() Set IExplorer = CreateObject("InternetExplorer.Application") IExplorer.Visible = True IExplorer.navigate "http://avotus/avotus/" Do While IExplorer.Busy And Not IExplorer.ReadyState = 4: Application.Wait (Now + TimeValue("0:00:02")) DoEvents Loop With Selection IExplorer.document.all("Login").Value = "sl704d" IExplorer.document.all("Password").Value = "******" IExplorer.document.forms(0).submit End With End Sub It opens the webpage perfectly, but gives me an error at the With Selection line. I have managed to save the HTML for just the login frame and I have run the macro successfully against this, so I'm thinking that it's not identifying the frames on the webpage right. My HTML programming is very limited, so that's maybe my biggest problem. Thank's in advance for any help. -- Cheers... |
Selecting frame in Internet Explorer from Excel
John,
That worked perfectly, I'm now logged into the website. Thank you very much for your help. Cheers... "John" wrote: Hi Deke, I'm not very clued up on navigating in IE, but have done some interesting digging and found the following link: http://www.dailydoseofexcel.com/arch...rnet-explorer/ If you're trying to target a specific frame then you might want to try looping through the frames to check the name of the one you're after: For x = 0 To IExplorer.Document.Frames.Length - 1 Debug.Print IExplorer.Document.Frames(x).Name Next x You could then target the correct frame with something like: IExplorer.Document.Frames("fraTarget").Document... ... Also, its worth stepping through your code (F8) as once you've got a reference to the document you can explore all of the elements via the Locals window. Anyway, hope that helps. Best regards John "Deke" wrote in message ... I am trying to logon to a website from the Excel Macro, but cannot get it to use the correct frame on the web page. There seems to be 2 main frames to the webpage, the login and password one, that I'm trying to use, and then the rest of the page. Below is the code I am using, I got it from another thread in the discussion group. Sub Open_Website() Set IExplorer = CreateObject("InternetExplorer.Application") IExplorer.Visible = True IExplorer.navigate "http://avotus/avotus/" Do While IExplorer.Busy And Not IExplorer.ReadyState = 4: Application.Wait (Now + TimeValue("0:00:02")) DoEvents Loop With Selection IExplorer.document.all("Login").Value = "sl704d" IExplorer.document.all("Password").Value = "******" IExplorer.document.forms(0).submit End With End Sub It opens the webpage perfectly, but gives me an error at the With Selection line. I have managed to save the HTML for just the login frame and I have run the macro successfully against this, so I'm thinking that it's not identifying the frames on the webpage right. My HTML programming is very limited, so that's maybe my biggest problem. Thank's in advance for any help. -- Cheers... |
All times are GMT +1. The time now is 11:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com