Ganeshja
Ganeshja

Reputation: 2765

How to click a Link on a webpage using VBScript

Actually i have to click on a link and as a result it will be give two menu list in that i need to select any of those

here is my VBScript for launching IE and navigate to required web adress

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL

Can any any one help me out to click on that link and select any one of those menu source for the link

Actual source for the link :

<a id="zz13_ListActionsMenu" accesskey="C" href="#" onclick="javascript:return false;" style="cursor ointer;white-space:nowrap;" onfocus="MMU_EcbLinkOnFocusBlur(byid('zz8_RptControls'), this, true);" onkeydown="MMU_EcbLinkOnKeyDown(byid('zz8_RptControls'), MMU_GetMenuFromClientId('zz13_ListActionsMenu'), event);" oncontextmenu="this.click(); return false;" menutokenvalues="MENUCLIENTID=zz13_ListActionsMenu,TEMPLATECLIENTID=zz8_RptControls" serverclientid="zz13_ListActionsMenu">Actions<img src="/_layouts/images/blank.gif" border="0" alt="Use SHIFT+ENTER to open the menu (new window)."></a>

Thanks in advance

Upvotes: 1

Views: 22617

Answers (1)

Sudhir
Sudhir

Reputation: 1472

For this scenario you can use the method "getElementById". For example:

IE.Document.getElementById("zz13_ListActionsMenu").Click

So your code will look something like:

Dim URL 
Dim IE 
Set IE = CreateObject("internetexplorer.application")
URL = "http://it-asg.uhc.com/sites/gcas/pcas/archive/PCR/IVM/modlist/Lists/ElementTracker/AllItems.aspx" 
IE.Visible = True
IE.Navigate URL


 Do While IE.Busy
    WScript.Sleep 100
 Loop

IE.Document.getElementById("zz13_ListActionsMenu").Click

There are also other methods you can use to access and click elements on a page, I refer to the following for a list:

http://msdn.microsoft.com/en-us/library/ie/ms535862(v=vs.85).aspx

Upvotes: 3

Related Questions