Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jaf jaf is offline
external usenet poster
 
Posts: 300
Default fill a web form from excel vba

Wild guess. (yes, I'm guessing)
What data type is the form field set to receive?

myDoc.forms(0).UserName.Value = strSearch
should be
myDoc.forms(0).UserName.Value = char(34) & strSearch & char(34)
or maybe
myDoc.forms(0).UserName.Value = """ & strSearch & """
or maybe
myDoc.forms(0).UserName.Text= strSearch

John

"luigimut" wrote in message
...
I have a quite complex issue that I am trying to solve (the Italian excel
newsgroup hasnt give me any answer at the moment).
The goal is to create an excel macro written in VBA that should effect the
following: a) open a IExplorer window containing a form (username and
password) b) fill the form automatically with the given username and
password
and submit the form.
The form is part of an SQL database running on the company server.

By looking for solutions on internet I found several solutions that work,
for instance on the Google search window.
One of them adapted and working is the following:

QUOTE


Sub FILLWEBFORMGOOGLE() ' IT WORKS ON GOOGLE!!!!!!!!!!!!!!

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"

'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myDoc As HTMLDocument
Dim strSearch As String

'Set starting URL and search string
myURL = "http://google.com"
strSearch = "pippo"

'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

'Set IE document into object

Set myDoc = myIE.document

'Enter search string on form

myDoc.forms(0).q.Value = strSearch

'Submit form
myDoc.f.submit

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

MsgBox myIE.LocationName

End Sub

UNQUOTE

I tried then to apply the same scheme to my case but the macro doesnt
work.
The code used was the following

QUOTE

Sub FILLWEBFORM()

'This project includes references to "Microsoft Internet Controls" and
'"Microsoft HTML Object Library"

'Variable declarations
Dim myIE As New InternetExplorer 'New '
Dim myURL As String
Dim myDoc As HTMLDocument
Dim strSearch As String

'Set starting URL and search string
myURL = "http://ro-srv9/nostrogestionale/"
strSearch = "pippo"

'Make IE navigate to the URL and make browser visible
myIE.navigate myURL
myIE.Visible = True

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

'Set IE document into object

Set myDoc = myIE.document

'Enter search string on form

myDoc.forms(0).UserName.Value = strSearch

'Submit form
myDoc.contest.submit

'Wait for the page to load
Do While myIE.Busy Or myIE.readyState < READYSTATE_COMPLETE
DoEvents
Loop

MsgBox myIE.LocationName

End Sub

UNQUOTE

The problem is probably due to the syntax to identify the form and the
element UserName in the HTML. The last one should be filled with the text
€śpippo€ť. Probably the code


myDoc.forms(0).UserName.Value = strSearch

is wrong (its there where the macro is stuck)


I dont know how to write this code in order to obtain the result. Can
anybody help me on this issue? Can You also suggest articles and
literature
on this topic?

Thanks for Your cooperation (I add also the HTML code of the IExplorer
window containing the form that I have to fill, in case is useful)


<HTML
<HEAD
<TITLELogin</TITLE
<LINK REL="stylesheet" HREF="Library/Ccs/style.css"
<SCRIPT LANGUAGE="JavaScript" SRC="Help/HelpLib.js"</script
<STYLE TYPE="text/css"
.titolo, .messaggio
{
font-family: Trebuchet Ms;
font-size: 10pt;
font-weight: bold;
text-align: right;
}
.messaggio
{
text-align: center;
color: #CC0000;
}
</STYLE
<SCRIPT LANGUAGE="JavaScript"
function START()
{
var f = document.contest;
parent.alto.location.href = "Testata.asp";
}
</SCRIPT
</HEAD

<BODY onLoad="START()"
<DIV VALIGN="center" ALIGN="RIGHT"

<TABLE width=100% border=0 cellpadding=0 cellspacing=0
<TR align=left
<TD align=left valign=bottom width=100%
<FONT class=SID_PageTitleSistema Gestionale societa</FONT<BR
<FONT class=SID_SubTitleProcedura di Logon</FONT
<HR
</TD
</TR
<TR
<TD
<FORM NAME="contest" ACTION="Login.asp" METHOD="post"


<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="80%"
<TR
<TD CLASS="titolo"UserName </TD
<TD <INPUT NAME="UserName" MAXLENGTH="50"</TD
</TR
<TR
<TD CLASS="titolo"Password </TD
<TD <INPUT TYPE="password" NAME="password" MAXLENGTH="20"</TD
</TR
</TABLE

<TABLE CLASS="CMD_Table" WIDTH=100%<TR
<TD CLASS="CMD_TableCell" align="right"
<INPUT type=submit name=btnLogin CLASS="BTN_Comandi" value="ENTRA"
</TD
</TR</TABLE

</FORM
</TD
</TR
</TABLE

</DIV
</BODY
</HTML


Reply
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
How do i get an form to fill up my excel sheet? raj Excel Discussion (Misc queries) 1 May 16th 09 04:12 PM
fill a web form from excel vba luigimut Excel Programming 0 June 12th 08 11:03 AM
Fill in form to type Item descrictions and costs and fill in funct cradino Excel Worksheet Functions 0 July 16th 06 08:44 PM
Excel as fill-in form Sashacat7 Excel Discussion (Misc queries) 1 January 25th 06 06:21 PM
Fill Excel Screen with Form Lydon Bergin Excel Programming 4 January 20th 06 07:17 PM


All times are GMT +1. The time now is 09:39 PM.

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

About Us

"It's about Microsoft Excel"