Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you want to set the focus to a specific link, this code should do the
trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
its not working for me because i dont think it is an <a href ... link per se. It is more like: <tr onclick="goTo('/Reports/ReportList.asp', '')" <td width="26"<img src="/Shared/Images/Icons/smallIcon_View.gif"</td <td nowrap class="MenuItem"View Reports</td <td </td </tr not sure what to do about this... would it be better to list the files stored in the url? if so how can that be done? thanks in advance, geebee "AndyM" wrote: If you want to set the focus to a specific link, this code should do the trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is this an external site that we have access to? If so, can you post the link?
If you click on the image (smallIcon_View.gif), will it navigate to the desired link? If so, here is code to click on the image. For this code you'll either need error handling or On Error Resume Next, since not every html object has a src property. I use InStr to compare the image src property against the value you are looking for (findSrc). This way you only have to enter the image file name.. not the entire path. 'loop through all objects within the document For Each htmlObj In ie.Document.All 'get the inner text of the link imgSrc = UCase(Trim(htmlObj.src)) If InStr(1, imgSrc, UCase(findSrc)) < 0 Then 'found match, set focus objLink.Focus Exit For End If Next htmlObj If this doesn't work, it looks like you may be able to click on the "View Reports" text since that appears to be a menu link. In this case, you would just search through the html objects looking for an object that has an innerText property value of "View Reports". "geebee" wrote: hi, its not working for me because i dont think it is an <a href ... link per se. It is more like: <tr onclick="goTo('/Reports/ReportList.asp', '')" <td width="26"<img src="/Shared/Images/Icons/smallIcon_View.gif"</td <td nowrap class="MenuItem"View Reports</td <td </td </tr not sure what to do about this... would it be better to list the files stored in the url? if so how can that be done? thanks in advance, geebee "AndyM" wrote: If you want to set the focus to a specific link, this code should do the trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
i think i may go a different route... i have code which clicks on a link.. .the only problem is sometimes the exact link address is not known. for example, the following link works fine: https://secure.secure.com/Transactio...0CH-20SENT.pdf i did some testing and it looks lke the first part of the "5005_46_16_AppServiceUser_20080923200402123_Z Z-2DRLSD-20CH-20SENT.pdf" (meaning the "5005_46_16_AppServiceUser_200809" and the "ZZ-2DRLSD-20CH-20SENT.pdf" part stay the same. But sometimes the "23200402123" part is not known. is there anyway we can do a loop through the different possibilities or somehting so that we can arrive at the "23200402123" part? this wil lbe very useful when the exact filename is not known. thanks in advance, geebee "AndyM" wrote: Is this an external site that we have access to? If so, can you post the link? If you click on the image (smallIcon_View.gif), will it navigate to the desired link? If so, here is code to click on the image. For this code you'll either need error handling or On Error Resume Next, since not every html object has a src property. I use InStr to compare the image src property against the value you are looking for (findSrc). This way you only have to enter the image file name.. not the entire path. 'loop through all objects within the document For Each htmlObj In ie.Document.All 'get the inner text of the link imgSrc = UCase(Trim(htmlObj.src)) If InStr(1, imgSrc, UCase(findSrc)) < 0 Then 'found match, set focus objLink.Focus Exit For End If Next htmlObj If this doesn't work, it looks like you may be able to click on the "View Reports" text since that appears to be a menu link. In this case, you would just search through the html objects looking for an object that has an innerText property value of "View Reports". "geebee" wrote: hi, its not working for me because i dont think it is an <a href ... link per se. It is more like: <tr onclick="goTo('/Reports/ReportList.asp', '')" <td width="26"<img src="/Shared/Images/Icons/smallIcon_View.gif"</td <td nowrap class="MenuItem"View Reports</td <td </td </tr not sure what to do about this... would it be better to list the files stored in the url? if so how can that be done? thanks in advance, geebee "AndyM" wrote: If you want to set the focus to a specific link, this code should do the trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Will the "ZZ-2DRLSD-20CH-20SENT.pdf" part uniquely identify the link? If so,
just do a partial match using the InStr function. Dim lookFor As String lookFor = "ZZ-2DRLSD-20CH-20SENT.pdf" If InStr(1, aLink, lookFor) < 0 Then 'found it End If "geebee" wrote: hi, i think i may go a different route... i have code which clicks on a link.. .the only problem is sometimes the exact link address is not known. for example, the following link works fine: https://secure.secure.com/Transactio...0CH-20SENT.pdf i did some testing and it looks lke the first part of the "5005_46_16_AppServiceUser_20080923200402123_Z Z-2DRLSD-20CH-20SENT.pdf" (meaning the "5005_46_16_AppServiceUser_200809" and the "ZZ-2DRLSD-20CH-20SENT.pdf" part stay the same. But sometimes the "23200402123" part is not known. is there anyway we can do a loop through the different possibilities or somehting so that we can arrive at the "23200402123" part? this wil lbe very useful when the exact filename is not known. thanks in advance, geebee "AndyM" wrote: Is this an external site that we have access to? If so, can you post the link? If you click on the image (smallIcon_View.gif), will it navigate to the desired link? If so, here is code to click on the image. For this code you'll either need error handling or On Error Resume Next, since not every html object has a src property. I use InStr to compare the image src property against the value you are looking for (findSrc). This way you only have to enter the image file name.. not the entire path. 'loop through all objects within the document For Each htmlObj In ie.Document.All 'get the inner text of the link imgSrc = UCase(Trim(htmlObj.src)) If InStr(1, imgSrc, UCase(findSrc)) < 0 Then 'found match, set focus objLink.Focus Exit For End If Next htmlObj If this doesn't work, it looks like you may be able to click on the "View Reports" text since that appears to be a menu link. In this case, you would just search through the html objects looking for an object that has an innerText property value of "View Reports". "geebee" wrote: hi, its not working for me because i dont think it is an <a href ... link per se. It is more like: <tr onclick="goTo('/Reports/ReportList.asp', '')" <td width="26"<img src="/Shared/Images/Icons/smallIcon_View.gif"</td <td nowrap class="MenuItem"View Reports</td <td </td </tr not sure what to do about this... would it be better to list the files stored in the url? if so how can that be done? thanks in advance, geebee "AndyM" wrote: If you want to set the focus to a specific link, this code should do the trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi,
i decided to go a different route yesterday because it does not appear that the links are actually <a href... links. so will the code you suggested still work? if not, i have code which clicks on a link.. .the only problem is sometimes the exact link address is not known. for example, the following link works fine: https://secure.secure.com/Transactio...0CH-20SENT.pdf i did some testing and it looks lke the first part of the "5005_46_16_AppServiceUser_20080923200402123_Z Z-2DRLSD-20CH-20SENT.pdf" (meaning the "5005_46_16_AppServiceUser_200809" and the "ZZ-2DRLSD-20CH-20SENT.pdf" part stay the same. But sometimes the "23200402123" part is not known. is there anyway we can do a loop through the different possibilities or somehting so that we can arrive at the "23200402123" part? this wil lbe very useful when the exact filename is not known. i looked at the source code for the page...(which made me think that the links are not <a href... links) but i could be wrong: <ReportList <Report Created="7/27/2008 00:46" UTC="-128616112044438057" File="1101_46_16_AppServiceUser_20080727004644600. txt" Name="Submission" Size="2" User="AppServiceUser" Type="Submission" Format="TXT" Filter="" Allow="1" Delete="false" Download="false" IsNew="true" / "AndyM" wrote: Will the "ZZ-2DRLSD-20CH-20SENT.pdf" part uniquely identify the link? If so, just do a partial match using the InStr function. Dim lookFor As String lookFor = "ZZ-2DRLSD-20CH-20SENT.pdf" If InStr(1, aLink, lookFor) < 0 Then 'found it End If "geebee" wrote: hi, i think i may go a different route... i have code which clicks on a link.. .the only problem is sometimes the exact link address is not known. for example, the following link works fine: https://secure.secure.com/Transactio...0CH-20SENT.pdf i did some testing and it looks lke the first part of the "5005_46_16_AppServiceUser_20080923200402123_Z Z-2DRLSD-20CH-20SENT.pdf" (meaning the "5005_46_16_AppServiceUser_200809" and the "ZZ-2DRLSD-20CH-20SENT.pdf" part stay the same. But sometimes the "23200402123" part is not known. is there anyway we can do a loop through the different possibilities or somehting so that we can arrive at the "23200402123" part? this wil lbe very useful when the exact filename is not known. thanks in advance, geebee "AndyM" wrote: Is this an external site that we have access to? If so, can you post the link? If you click on the image (smallIcon_View.gif), will it navigate to the desired link? If so, here is code to click on the image. For this code you'll either need error handling or On Error Resume Next, since not every html object has a src property. I use InStr to compare the image src property against the value you are looking for (findSrc). This way you only have to enter the image file name.. not the entire path. 'loop through all objects within the document For Each htmlObj In ie.Document.All 'get the inner text of the link imgSrc = UCase(Trim(htmlObj.src)) If InStr(1, imgSrc, UCase(findSrc)) < 0 Then 'found match, set focus objLink.Focus Exit For End If Next htmlObj If this doesn't work, it looks like you may be able to click on the "View Reports" text since that appears to be a menu link. In this case, you would just search through the html objects looking for an object that has an innerText property value of "View Reports". "geebee" wrote: hi, its not working for me because i dont think it is an <a href ... link per se. It is more like: <tr onclick="goTo('/Reports/ReportList.asp', '')" <td width="26"<img src="/Shared/Images/Icons/smallIcon_View.gif"</td <td nowrap class="MenuItem"View Reports</td <td </td </tr not sure what to do about this... would it be better to list the files stored in the url? if so how can that be done? thanks in advance, geebee "AndyM" wrote: If you want to set the focus to a specific link, this code should do the trick. The findText variable will contain the link text you want to set focus to. 'loop through all links within the document For Each objLink In ie.Document.Links 'get the inner text of the link linkText = objLink.innertext If UCase(Trim(linkText)) = UCase(findText) Then 'found match, set focus objLink.Focus Exit For End If Next objLink If you want to actually click the link, just change .Focus to .Click, but then you'll want some to add some code to wait for IE to finish loading. Post back if you have additional questions. I have used Excel VBA to automate the testing of several Web applications. In most cases, it works very well. "geebee" wrote: hi, i have some code that goes to a website... i noticed that when you hit "TAB" within that website you cannot put the focus on the desired link. so i need to see if there is a way to move focus to the window within the IE window using VBA ... thanks in advance, geebee |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Parent/Child Macro | Excel Programming | |||
Parent/Child Field | Excel Programming | |||
Get only child nodes? | Excel Programming | |||
The window opens in a smaller window not full sized window. | Excel Discussion (Misc queries) | |||
How to assign an object to a child IE window | Excel Programming |