Public Member Error

E

Erica Roberts

I am attempting to write some code that auto submits to a few search
engines. The code is crashing when submitting to DMOZ on the
wbbrowser.document.all("submit").click() line. This same line of code works
on Yahoo but not when done the 2nd time under DMOZ. My code is below. the
DMOZ Code is the last set.

The error I am getting is Public member 'click' on type
'DISPHTMLELEMENTCollection' no found.

Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdStart.Click

Dim i As Integer

Dim SubUrl As String

Dim SubName As String

Dim SubTitle As String

Dim SubDesc As String

Dim SubEmail As String

Dim SubKeywords As String



If Me.lsvDomains.Items.Count > 0 Then



For i = 0 To Me.lsvDomains.Items.Count - 1

If Me.lsvDomains.Items(i).Checked Then

SubUrl = Me.lsvDomains.Items(i).Text

SubTitle = Me.lsvDomains.Items(i).SubItems(1).Text

SubName = Me.lsvDomains.Items(i).SubItems(2).Text

SubEmail = Me.lsvDomains.Items(i).SubItems(3).Text

SubDesc = Me.lsvDomains.Items(i).SubItems(4).Text

''********Submit to Yahoo

Dim URL As String = "http://add.yahoo.com/fast/add?158789" '

Dim Flags As Integer = 0

Dim TargetFrame As String = ""

Dim PostData As Object =
"category=Reference&spaceid=158789&noexpress=1&class=YHOO&pass=2"

PostData = System.Text.Encoding.GetEncoding(1252).GetBytes(PostData)

Dim Headers = "Content-Type: application/x-www-form-urlencoded" & vbCrLf

Me.wbBrowser.Navigate(URL, Flags, TargetFrame, PostData, Headers)

Do

Application.DoEvents()

Loop While Me.wbBrowser.Busy



wbBrowser.Document.All("title").Value = SubTitle

wbBrowser.Document.All("url").Value = "http://" + SubUrl

'wbBrowser.Document.All("location").Value = txtlocation.Text

wbBrowser.Document.All("comments").Value = SubDesc

wbBrowser.Document.All("name").Value = SubName

wbBrowser.Document.All("email").Value = SubEmail

wbBrowser.Document.All(".submit").Click()

Do

Application.DoEvents()

Loop While Me.wbBrowser.Busy

''******Google.com

Me.wbBrowser.Navigate("http://www.google.com/addurl?q=http://" +
SubUrl + "&dq=&submit=Add+URL")

Do

Application.DoEvents()

Loop While Me.wbBrowser.Busy

''*****Dmoz.com (Open Directory Project)

wbBrowser.Navigate("http://dmoz.org/cgi-bin/add.cgi?where=Regional/North_Ame
rica/United_States/Ohio/Business_and_Economy/Real_Estate")

Do

Application.DoEvents()

Loop While Me.wbBrowser.Busy

wbBrowser.Document.all("url").value = SubUrl

wbBrowser.Document.all("title").value = SubTitle

wbBrowser.Document.all("description").value = SubDesc

wbBrowser.Document.all("email").value = SubEmail

wbBrowser.Document.all("submit").click()





End If

Do

Application.DoEvents()

Loop While Me.wbBrowser.Busy

Next



End If



End Sub
 
F

Fredrik Melin

Are you sure it works the first time on DMOZ? I am pretty sure it dont.

The error is because the page on DMOZ has two Submit tags, one <a
name="submit"> link and one button, you get a collection, therefor it dont
have a click() function.

a dirty fix would be
wbBrowser.Document.All("submit").item(0).click()

Or

wbBrowser.Document.All("submit").item(1).click()

depending if the button comes first or last...

Regards

Fredrik Melin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top