Re: Carets and Forms

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Greg Bilik" <gjbilik@xxxxxxxxx> wrote
> Hi Mark,
>
> My apologies if I wasn't clear. First of all I am using MS Internet
> Explorer. Second, the CGI form is an existing web page provided by a third
> party to perform tasks, which is password protected to use it. The task may
> need to be repeated several hundred times and the third party does not
> provide a file input method of obtaining results. I thought that I could
> write a program which writes data to the form from a delimited file to save
> from having to cut and paste over and over. As of now I can write data to
> the form on the screen the user then processes the data, returns to the form
> page and continues my program to write the next set of data. However, the
> user must also place the caret in the first box on the form in order to have
> my program correctly fill in the form. My thinking was that I could require
> the user to place the caret in the form the first time, they have to enter
> their userid and password anyway, and then get the position of the caret
> from the form using the GetCaretPos API call. This doesn't work, even
> though the caret is blinking in the first field of the form when my program
> begins to write data to the form on the screen. I have been told that
> Windows controls like GetCaret and GetCursor don't function within forms. I
> was wondering if there was any other function which may be able to do the
> same thing as the GetCaretPos and SetCaretPos. I'm thinking that Windows
> has to know where the caret is even if it is inside of a form.
>
> I hope this helps to clear up what my problem is. Thanks for any help.


As long as you are using Internet Explorer, you can pretty well control it
to do as you need. For example, you may be able to deposit your data
directly on the form through the web documents Document object model.

For a simple example, add 3 textboxes and a command button to a new
form, then add a Reference to 'Microsoft Internet Controls'. Paste in the
code below and note how it is able to move the text from the 3 textboxes
on to the search form at the press of the button.

HTH
LFS

Option Explicit
Private WithEvents IE As SHDocVw.InternetExplorer
Private Intercept As Boolean
Private Ready As Boolean

Private Sub Command1_Click()
Dim doc, ele
If Ready Then
Set doc = IE.Document
Set ele = doc.All("as_q")
ele.Value = Text1.Text
Set ele = doc.All("as_uauthors")
ele.Value = Text2.Text
Set ele = doc.All("as_usubject")
ele.Value = Text3.Text
Set ele = doc.All("as_ugroup")
ele.Value = "microsoft.public.vb.*"
Intercept = True
MsgBox "Inspect the form, and press the Search button"
End If
End Sub

Private Sub Form_Load()
Set IE = New SHDocVw.InternetExplorer
IE.Visible = True
IE.Navigate "http://groups-beta.google.com/advanced_search";
End Sub

Private Sub IE_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As
Variant, Headers As Variant, Cancel As Boolean)
Ready = False
Debug.Print "waiting for document"
End Sub

Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Me.SetFocus
If pDisp Is IE Then
Ready = True
If Intercept Then
MsgBox "The data has been accepted"
Intercept = False
Ready = False
IE.Navigate "http://groups-beta.google.com/advanced_search";
End If
End If
End Sub




.


Quantcast