Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Folks
I am having trouble trying to get VBA to click on an image on a web page. The HTML java code is as follows: (sendsmsform is a function) <!--<input type="button" name="submitsms" value="send your message" onClick="sendsmsform();"-- <a href="#" onClick="sendsmsform();"<img src="/messaging/send_message.jpg" alt="send message" border="0" /</a My VBA code is as follows: Private Sub SMS_STORE_FIGURES_TO_MANAGERS_2() Dim i As Long Dim IE As Object Dim objElement As Object Dim objCollection As Object ' Create InternetExplorer Object Set IE = CreateObject("InternetExplorer.Application") ' You can uncoment Next line To see form results IE.Visible = True ' Send the form data To URL As POST binary request IE.Navigate "http://intranet/cgi-bin/sms.pl?trig=template" ' Statusbar Application.StatusBar = "messaging is loading. Please wait..." ' Wait while IE loading... 'IE.Navigate2 URL Do While IE.readyState < 4 DoEvents Loop Do While IE.Busy = True DoEvents Loop Application.StatusBar = "Search form submission. Please wait..." Set objCollection = IE.Document.getElementsByTagName("input") i = 0 While i < objCollection.Length If objCollection(i).Name = "Number" Then ' Set text for search objCollection(i).Value = "07971411105" End If i = i + 1 Wend Set objCollection = IE.Document.getElementsByTagName("textarea") i = 0 While i < objCollection.Length If objCollection(i).Name = "Message" Then ' Set text for search objCollection(i).Value = "07971411105" End If i = i + 1 Wend Set objCollection = IE.Document.getElementsByTagName("textarea") i = 0 While i < objCollection.Length If objCollection(i).Name = "Message" Then ' Set text for search objCollection(i).Value = "Neil is SOOOO COOOOL" End If i = i + 1 Wend Set objCollection = IE.Document.getElementsByTagName("input") i = 0 While i < objCollection.Length If objCollection(i).Name = "readit" Then ' Set text for search Set objElement = objCollection(i) objElement.Click End If i = i + 1 Wend Set objCollection = IE.Document.getElementsByTagName("img") ' Set text for search Set objElement = objCollection objElement.onclick ' Wait while IE re-loading... Do While IE.Busy Application.Wait DateAdd("s", 1, Now) Loop ' Show IE IE.Visible = True ' Clean up Set IE = Nothing Set objElement = Nothing Set objCollection = Nothing Application.StatusBar = "" End Sub If you need the Full Code for the web page I can add this although its a company internal page so you will not be able to view it. -- Nelly |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Sorry but i am stuck again | New Users to Excel | |||
Supressing the ctrl-c and other keys during word automation in automation | Excel Programming | |||
Help, please, I'm stuck | Excel Discussion (Misc queries) | |||
Stuck | Excel Programming | |||
stuck please help | Excel Programming |