Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Code is simple... and there is no error in code (that VBA discerns) but the
sendkeys commands do not move the cursor in the new IE window and doesn't send the active cell value either. Any thoughts? Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://whatever.com" .resizable = True End With 'App.Activate "Microsoft Internet Explorer" SendKeys "{TAB}" SendKeys ActiveCell.Value SendKeys "~" |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John, are you trying to fill in a form on a webpage or send a command to the
browser itself (such as "open page www.123.com)? If you are trying to fill in a form on a page, my first guess is that you aren't waiting long enough for the page to fully load. With the following code I was able to browse to www.funny.com and enter "test" into the search box. Sendkeys is very finicky and I would only use it as a last resort. If the web page orientation (layout, tab-index, etc.) ever changes, your code will break. Regards, Bill Public Sub Test_IESendkeys() Dim i As Long Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://www.funny.com" .resizable = True End With Application.Wait (Now + TimeValue("0:00:10")) 'App.Activate "Microsoft Internet Explorer" For i = 1 To 15 SendKeys "{TAB}" Next i SendKeys "test" 'SendKeys "~" End Sub "John" wrote: Code is simple... and there is no error in code (that VBA discerns) but the sendkeys commands do not move the cursor in the new IE window and doesn't send the active cell value either. Any thoughts? Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://whatever.com" .resizable = True End With 'App.Activate "Microsoft Internet Explorer" SendKeys "{TAB}" SendKeys ActiveCell.Value SendKeys "~" |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the response Bill... it was a time thing... I am trying to launch
a new window and then dump a cell value into a search on a website. This works by adding that wait command... I realize that if the website changes the code is no good... is there a way around that? "Bill Pfister" wrote: John, are you trying to fill in a form on a webpage or send a command to the browser itself (such as "open page www.123.com)? If you are trying to fill in a form on a page, my first guess is that you aren't waiting long enough for the page to fully load. With the following code I was able to browse to www.funny.com and enter "test" into the search box. Sendkeys is very finicky and I would only use it as a last resort. If the web page orientation (layout, tab-index, etc.) ever changes, your code will break. Regards, Bill Public Sub Test_IESendkeys() Dim i As Long Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://www.funny.com" .resizable = True End With Application.Wait (Now + TimeValue("0:00:10")) 'App.Activate "Microsoft Internet Explorer" For i = 1 To 15 SendKeys "{TAB}" Next i SendKeys "test" 'SendKeys "~" End Sub "John" wrote: Code is simple... and there is no error in code (that VBA discerns) but the sendkeys commands do not move the cursor in the new IE window and doesn't send the active cell value either. Any thoughts? Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://whatever.com" .resizable = True End With 'App.Activate "Microsoft Internet Explorer" SendKeys "{TAB}" SendKeys ActiveCell.Value SendKeys "~" |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Rather than use SendKeys, you should be interacting with the web page
directly. For example, something like: Set oIE = New InternetExplorer oIE.Visible = True oIE.Navigate Range("sURL") Do: DoEvents: Loop Until oIE.ReadyState = READYSTATE_COMPLETE Set oForm = oIE.Document.forms(0) oForm("name1").Value = "Value1" oForm("name2").Value = "Value2" oForm("submitname").Click Do: DoEvents: Loop While oIE.Busy Do: DoEvents: Loop Until oIE.ReadyState = READYSTATE_COMPLETE Set oForm = oIE.Document.forms(0) oForm("cancelname").Click |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Firstly, let me disclaim my reference to www.funny.com. I have no
accociation with the site - it just happened to be the site that popped up when I entered "whatever.com". If the objects on the page are tagged, you can get a better "grip" when you're trying to access them. You can find out by looking at the page source and try to find a name property. In the "funny.com" site, you'll see that the search field has a name: <input class="formItem" size="10" type=text value="" name="0.7.31.1.3". You can "tie" to this object with more elaborate code. You will still be at the mercy of the site designers if they change the control name, but it is considerably more reliable than using the tab index. I haven't written code tie directly to an object embedded in a webpage, although I know sample code is out there. "John" wrote: Thanks for the response Bill... it was a time thing... I am trying to launch a new window and then dump a cell value into a search on a website. This works by adding that wait command... I realize that if the website changes the code is no good... is there a way around that? "Bill Pfister" wrote: John, are you trying to fill in a form on a webpage or send a command to the browser itself (such as "open page www.123.com)? If you are trying to fill in a form on a page, my first guess is that you aren't waiting long enough for the page to fully load. With the following code I was able to browse to www.funny.com and enter "test" into the search box. Sendkeys is very finicky and I would only use it as a last resort. If the web page orientation (layout, tab-index, etc.) ever changes, your code will break. Regards, Bill Public Sub Test_IESendkeys() Dim i As Long Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://www.funny.com" .resizable = True End With Application.Wait (Now + TimeValue("0:00:10")) 'App.Activate "Microsoft Internet Explorer" For i = 1 To 15 SendKeys "{TAB}" Next i SendKeys "test" 'SendKeys "~" End Sub "John" wrote: Code is simple... and there is no error in code (that VBA discerns) but the sendkeys commands do not move the cursor in the new IE window and doesn't send the active cell value either. Any thoughts? Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://whatever.com" .resizable = True End With 'App.Activate "Microsoft Internet Explorer" SendKeys "{TAB}" SendKeys ActiveCell.Value SendKeys "~" |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
John,
Depending on how this server handles the input, can you .Navigate2 the URL that would exist after you have entered the criteria and clicked the button ? e.g. This link takes you directly to Googles results page http://www.google.co.uk/search?hl=en...=Google+Search You can build the required string with your ActiveCell.Value and go there directly. NickHK "John" wrote in message ... Code is simple... and there is no error in code (that VBA discerns) but the sendkeys commands do not move the cursor in the new IE window and doesn't send the active cell value either. Any thoughts? Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True .navigate "http://whatever.com" .resizable = True End With 'App.Activate "Microsoft Internet Explorer" SendKeys "{TAB}" SendKeys ActiveCell.Value SendKeys "~" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
In Excel, why does my VB not work when launched from IE ? | Excel Programming | |||
converting ppt to pdf launched from xls | Excel Programming | |||
converting ppt to pdf launched from xls | Excel Programming | |||
How do I determine how excel was launched | Excel Programming | |||
Can you tell how Excel is launched? | Excel Programming |