Code Comments
Programming Forum and web based access to our favorite programming groups.I have an auto search engine submission program. Here is one section of my
code:
Private Function SubmitDMOZ(url As String, email As String, title As String,
desc As String) As Boolean
Dim NavUrl As String
Me.RtfStatus.SelStart = Len(Me.RtfStatus.Text)
Me.RtfStatus.SelColor = vbBlack
Me.RtfStatus.SelText = vbNewLine & "Submitting " & Trim(url) & " to Open
Directory"
NavUrl =
"http://dmoz.org/cgi-bin/add.cgi?where=Regional/North_America/United_States/
Ohio/Business_and_Economy/Real_Estate"
Me.wbbrowser.Navigate NavUrl
Do
DoEvents
Loop While wbbrowser.Busy
Me.wbbrowser.Document.All("url").Value = Trim(url)
Me.wbbrowser.Document.All("title").Value = Trim(title)
Me.wbbrowser.Document.All("description").Value = Trim(desc)
Me.wbbrowser.Document.All("email").Value = Trim(email)
Me.wbbrowser.Document.All("submit")(1).Click
Do
DoEvents
Loop While wbbrowser.Busy
If wbtitle = "Submission Received" Then
SubmitDMOZ = True
Else
SubmitDMOZ = False
End If
End Function
---------------------
At the Me.wbbrowser.Document.All("url").Value = Trim(url) I get the
following error:
With block not set
Post Follow-up to this messageErica wrote:
> I have an auto search engine submission program. Here is one section
> of my code:
>
> Private Function SubmitDMOZ(url As String, email As String, title As
> String, desc As String) As Boolean
> Dim NavUrl As String
>
>
> Me.RtfStatus.SelStart = Len(Me.RtfStatus.Text)
> Me.RtfStatus.SelColor = vbBlack
> Me.RtfStatus.SelText = vbNewLine & "Submitting " & Trim(url) & "
> to Open Directory"
>
> NavUrl =
>
"http://dmoz.org/cgi-bin/add.cgi?where=Regional/North_America/United_States/
Ohio/Business_and_Economy/Real_Estate"
>
>
> Me.wbbrowser.Navigate NavUrl
> Do
> DoEvents
> Loop While wbbrowser.Busy
>
> Me.wbbrowser.Document.All("url").Value = Trim(url)
> Me.wbbrowser.Document.All("title").Value = Trim(title)
> Me.wbbrowser.Document.All("description").Value = Trim(desc)
> Me.wbbrowser.Document.All("email").Value = Trim(email)
> Me.wbbrowser.Document.All("submit")(1).Click
> Do
> DoEvents
> Loop While wbbrowser.Busy
>
> If wbtitle = "Submission Received" Then
> SubmitDMOZ = True
> Else
> SubmitDMOZ = False
> End If
>
>
> End Function
> ---------------------
>
> At the Me.wbbrowser.Document.All("url").Value = Trim(url) I get the
> following error:
>
> With block not set
Hi Erica,
I've tried your code in a test project (added a RichTextBox, a WebBrowser
and a CommandButton), and it seems to be working - somehow, if I declare the
wbtitle variable. Other than that, I'd made only minor, non-essential
adjustments.
Here's the modified code - it really shows the web page, then receives an
"incomplete data submitted" response.
'---------------------------------------------------------
Option Explicit: DefObj A-Z
Private Function SubmitDMOZ( _
url As String, email As String, _
title As String, desc As String _
) As Boolean
Dim NavUrl As String
Dim wbtitle As String ' ***FORMALLY***
On Error GoTo ErrHandler
With RtfStatus
.SelStart = Len(Me.RtfStatus.Text)
.SelColor = vbBlack
.SelText = vbNewLine & "Submitting " & Trim(url) & " to Open
Directory "
End With
NavUrl = _
"http://dmoz.org/cgi-bin/add.cgi?where=Regional/North_America/United_States/
Ohio/Business_and_Economy/Real_Estate"
With wbbrowser
.Navigate NavUrl
Do
DoEvents
Loop While .Busy
With .Document.All
.Item("url").Value = Trim$(url)
.Item("title").Value = Trim$(title)
.Item("description").Value = Trim$(desc)
.Item("email").Value = Trim$(email)
.Item("submit")(1).Click
End With
Do
DoEvents
Loop While .Busy
End With
If wbtitle = "Submission Received" Then ' ***???***
SubmitDMOZ = True
End If
Exit Function
ErrHandler:
Beep
With Err
Debug.Print "***Unexpected error*** : " & _
.Number & " (&H" & Hex$(.Number) & ")" & vbNewLine & _
vbNewLine & " Source : " & .Source & _
vbNewLine & " Descr : " & .Description
End With
End Function
Private Sub cmdGo_Click()
If SubmitDMOZ("", "", "", "") Then
Debug.Print "*OK*"
Else
Debug.Print "***Failed***"
End If
End Sub
'---------------------------------------------------------
hth
--
PZ
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.