LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Stuck on VBA Web Automation

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorry but i am stuck again KODIAK BEAR New Users to Excel 5 October 1st 07 08:46 PM
Supressing the ctrl-c and other keys during word automation in automation apondu Excel Programming 0 July 19th 07 10:10 PM
Help, please, I'm stuck Harvest Excel Discussion (Misc queries) 3 August 19th 06 03:28 AM
Stuck PaulOakley[_2_] Excel Programming 13 July 13th 05 05:54 PM
stuck please help derekc[_8_] Excel Programming 2 May 19th 04 06:08 AM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"