PDA

View Full Version : vba with web application



mlov83
04-30-2008, 03:41 AM
Hello everyone up to this point ive been able to just read everyone post and get my answers not bad for programing for about 3 years now. I have came across a real stumper :banghead: wondering if anyone can offer some help or solution.
I know how to fill out an html web form using vba excel however now i have an oracle web form that i like to do the same thing and i can't figuere out for the life of me how do to do it beside sending keys to the active screen. here is the code i use yet is unreliable because if you change focus from that screen then the send keys get send to the screen you set focus to.


Sub Test1()


Set IE = CreateObject("InternetExplorer.application") 'create the i.e exploer
IE.Visible = True
IE.Navigate ("there would be a link here but not allow to post") 'navigates to the website

Dim MyAppID, ReturnValue
Do
If IE.ReadyState = 4 Then 'checks is the page is finished
Exit Do
Else
DoEvents
End If
Loop
Ttabing
Wwating
End Sub

Sub Ttabing()
dim MyAppID, ReturnValue
'AppActivate "Microsoft Word" ' Activate Microsoft
Wwating
AppActivate "Oracle Developer Forms"
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1.5
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
SendKeys ("RUSS")
Wwating
SendKeys ("{TAB}")
Wwating
SendKeys ("RUSS")
Wwating
SendKeys ("{ENTER}")
Wwating
SendKeys ("HI")
End Sub


' this is wating function

Function Wwating()
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1.5
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End Function

I guess my ultimate question is how do i make a reference to a web application since it does not download any dll's and does not run on an html page. Hope someone has come across this before so far i have had luck finding anything like this.

Oorang
04-30-2008, 10:36 AM
Hello M,
Welcome to the board :) What you do is get the textboxes as objects then just feed the strings into their value property. The difficulty is that every webpage is different, so you have to check the page's source to see the object names. There is an example using G-Mail here: http://vbaexpress.com/kb/getarticle.php?kb_id=973


Make sure you set a reference to MSHTML.Dll and ShDocView.dll

mlov83
04-30-2008, 01:10 PM
Hello M,
Welcome to the board :) What you do is get the textboxes as objects then just feed the strings into their value property. The difficulty is that every webpage is different, so you have to check the page's source to see the object names. There is an example using G-Mail here:


Let me beging by saying thank you for the reply, i actually im aware of this method my isue is that this webform is actually not an html form this webform is a oracle web form that is brought up by a java applet. I would think the same concept would hold true but there are not object i'ds or anything to refer to atleast i dont now how to get them ( i guess what im trying to say is that there is no view source on the webpage here is the view source on the page.:banghead:

[code]
<OBJECT classid="clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF"
codebase="/forms/jinitiator/jinit13128.exe#Version=1,3,1,28"
WIDTH="0"
HEIGHT="0"
HSPACE="0"
VSPACE="0">
<PARAM NAME="TYPE" VALUE="application/x-jinit-applet;version=1.3.1.28">
<PARAM NAME="CODEBASE" VALUE="/forms/java">
<PARAM NAME="CODE" VALUE="oracle.forms.webutil.common.RegisterWebUtil" >
<PARAM NAME="ARCHIVE" VALUE="banwebutil.jar,jacob.jar,frmwebutil.jar" >
<COMMENT>
<EMBED SRC="" PLUGINSPAGE="/forms/jinitiator/us/jinit_download.htm"
TYPE="application/x-jinit-applet;version=1.3.1.28"
java_codebase="/forms/java"
java_code="oracle.forms.webutil.common.RegisterWebUtil"
java_archive="banwebutil.jar,jacob.jar,frmwebutil.jar"
WIDTH="1"
HEIGHT="1"
HSPACE="0"
VSPACE="0"
>
<NOEMBED>
</COMMENT>
</NOEMBED></EMBED>
</OBJECT>
<!-- Registration applet definition (end) -->
<!-- Forms applet definition (start) -->
<COMMENT id="forms_plugin_info"
plug_ver="clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF"
appheight="738"
appwidth="1040"
appcodebase="/forms/jinitiator/jinit13128.exe#Version=1,3,1,28">
</COMMENT>
<NOSCRIPT>
<OBJECT classid="clsid:CAFECAFE-0013-0001-0028-ABCDEFABCDEF"
codebase="/forms/jinitiator/jinit13128.exe#Version=1,3,1,28"
WIDTH="1040"
HEIGHT="738"
HSPACE="0"
VSPACE="0">
</NOSCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="java/forms_ie.js"></SCRIPT>
<PARAM NAME="TYPE" VALUE="application/x-jinit-applet;version=1.3.1.28">
<PARAM NAME="CODEBASE" VALUE="/forms/java">
<PARAM NAME="CODE" VALUE="oracle.forms.engine.Main" >
<PARAM NAME="ARCHIVE" VALUE="bannersso.jar,banspecial.jar,frmall_jinit.jar,banicons.jar,bannerui.jar,ban orep.jar,banwebutil.jar,jacob.jar,frmwebutil.jar" >
<PARAM NAME="serverURL" VALUE="/forms/lservlet?ifcfs=/forms/frmservlet?config=trng&acceptLanguage=en-us">
<PARAM NAME="networkRetries" VALUE="30">
<PARAM NAME="serverArgs"
VALUE="escapeParams=true module=guainit.fmx userid= sso_userid=%20 sso_formsid=%25OID_FORMSID%25 sso_subDN= sso_usrDN= debug=no host= port= buffer_records=no debug_messages=no array=no obr=no query_only=no quiet=yes render=no record= tracegroup= log= term=">
<PARAM NAME="separateFrame" VALUE="true">
<PARAM NAME="splashScreen" VALUE="no">
<PARAM NAME="background" VALUE="no">
<PARAM NAME="lookAndFeel" VALUE="Oracle">
<PARAM NAME="colorScheme" VALUE="blaf">
<PARAM NAME="serverApp" VALUE="default">
<PARAM NAME="logo" VALUE="no">
<PARAM NAME="imageBase" VALUE="codeBase">
<PARAM NAME="formsMessageListener" VALUE="">
<PARAM NAME="recordFileName" VALUE="">
<PARAM NAME="EndUserMonitoringEnabled" VALUE="">
<PARAM NAME="EndUserMonitoringURL" VALUE="">
<PARAM NAME="heartbeat" VALUE="">
<PARAM NAME="WebUtilLogging" VALUE="">
<PARAM NAME="WebUtilLoggingDetail" VALUE="">
<PARAM NAME="WebUtilErrorMode" VALUE="">
<PARAM NAME="WebUtilDispatchMonitorInterval" VALUE="">
<PARAM NAME="WebUtilTrustInternal" VALUE="">
<PARAM NAME="WebUtilMaxTransferSize" VALUE="">
<COMMENT>
<EMBED SRC="" PLUGINSPAGE="/forms/jinitiator/us/jinit_download.htm"
TYPE="application/x-jinit-applet;version=1.3.1.28"
java_codebase="/forms/java"
java_code="oracle.forms.engine.Main"
java_archive="bannersso.jar,banspecial.jar,frmall_jinit.jar,banicons.jar,bannerui.jar,ban orep.jar,banwebutil.jar,jacob.jar,frmwebutil.jar"
WIDTH="1040"
HEIGHT="738"
HSPACE="0"
VSPACE="0"
serverURL="/forms/lservlet?ifcfs=/forms/frmservlet?config=trng&acceptLanguage=en-us"
networkRetries="30"
serverArgs="escapeParams=true module=guainit.fmx userid= sso_userid=%20 sso_formsid=%25OID_FORMSID%25 sso_subDN= sso_usrDN= debug=no host= port= buffer_records=no debug_messages=no array=no obr=no query_only=no quiet=yes render=no record= tracegroup= log= term="
separateFrame="true"
splashScreen="no"
background="no"
lookAndFeel="Oracle"
colorScheme="blaf"
serverApp="default"
logo="no"
imageBase="codeBase"
formsMessageListener=""
recordFileName=""
EndUserMonitoringEnabled=""
EndUserMonitoringURL=""
heartBeat=""
WebUtilLogging=""
WebUtilLoggingDetail=""
WebUtilErrormode=""
WebUtilDispatchMonitorInterval=""
WebUtilTrustInternal=""
WebUtilMaxTransferSize=""
>
<NOEMBED>
</COMMENT>
</NOEMBED></EMBED>
</OBJECT>
<!-- Forms applet definition (end) -->
</BODY>
</HTML>

[\code]

if you can give me any other direction on this i would really appreciated it. im contemplating getting into the window API'S.:help

Oorang
04-30-2008, 01:27 PM
hmm I still think you can do it with IE. But as ever with these endeavors, you end up having to do a little RE. But you could use the API as well.

MattKlein
04-30-2008, 11:14 PM
mlov83,

What I would suggest is place a breakpoint in your code (F9 on a line of code) after you IE has finished loading, maybe when you call the "Ttabing" sub. Then run your code and it will pause during execution just before the function is called. Now you can see everything that is in memory. To se what is in your IE object's memroy, highlight "IE" (the object variable in your code), right click, and add it to the watch list. You may need to make the watch list visible from the toolbar. Now you will see "IE" with a little plus next to it in the watch list. Open the plus and you can see eveyrthing that is loaded in its memory. I'd start by looking under IE.document.forms.

Sorry if I'm babbling, its late for me and I'm on a computer without Office installed on it, so I'm giving directions from memory. If this isn't clear enough, please let me know and I'll repost with more detailed information.

Hope it helps!

-Matt

mlov83
05-01-2008, 06:20 AM
mlov83,

What I would suggest is place a breakpoint in your code (F9 on a line of code) after you IE has finished loading, maybe when you call the "Ttabing" sub. Then run your code and it will pause during execution just before the function is called. Now you can see everything that is in memory. To se what is in your IE object's memroy, highlight "IE" (the object variable in your code), right click, and add it to the watch list. You may need to make the watch list visible from the toolbar. Now you will see "IE" with a little plus next to it in the watch list. Open the plus and you can see eveyrthing that is loaded in its memory. I'd start by looking under IE.document.forms.

Sorry if I'm babbling, its late for me and I'm on a computer without Office installed on it, so I'm giving directions from memory. If this isn't clear enough, please let me know and I'll repost with more detailed information.

Hope it helps!

-Matt

Awesome tip and one i actually never new i could do. I think i found a new friend the "watch list" my problem now is that i need to understand the objects. can you help me with how i can leverage of those objects. for starers i went to document forms and all i saw was this
Document
Forms
lenght "0" type "long"
however i did notice a Applet object there are two items on there with tons of stuff.:think:
is there a way to refer to the internet explorer java applet via VBA or VB? then maybe after that i can perhaps refer to the objects in the applet... I dont know if this is possible. i really like to get away from using send keys, is not very reliable.

Oorang
05-01-2008, 07:08 AM
Document is referring to the type MSHTML.HTMLDocument, forms I'm not too sure about.

MattKlein
05-01-2008, 07:42 AM
i went to document forms and all i saw was this
Document
Forms
lenght "0" type "long"

the ie.document.forms is a collection object, the "length" is the number of items in the collection, 0 in this case. If there were 3 forms attached to the main page then ie.document.forms.length would = 3 and there would be "item 1", "item 2", "item 3" as HTMLFormElement in the collection.

I'm still trying to learn how/where sub-frames and non-standard items are located in the IE object... I have a page I'm trying to navigate through and I can't find a "link" in IE memory that I can see on the page... if anyone has any experience with this, please jump in!

But I digress... two ways to reference to "item 2" are with
oIE.Document.forms(1) (0 indexed)
or my preferred way...
oIE.Document.forms.nameditem("TargetForm")
where
oIE.Document.forms(1).name = "TargetForm"

then to reference to an element in "TargetForm" we can use either
oIE.Document.forms(1).nameditem("InputBox")
or
oIE.Document.nameditem("TargetForm").item(3) (again, 0 indexed)

I find this way much easier than viewing the page's source, plus if you have an input box you're trying to find, you can type in "Tada!" or whatever, then check
oIE.Document.forms(1).nameditem("InputBox").value
to see if it = "Tada!" (but make sure to refresh the watch window, I think just hitting the minus then plus again will do). If so, you're in business, if not, then keep checking...

Hope it helps!

-Matt

mlov83
05-02-2008, 06:39 AM
the ie.document.forms is a collection object, the "length" is the number of items in the collection, 0 in this case. If there were 3 forms attached to the main page then ie.document.forms.length would = 3 and there would be "item 1", "item 2", "item 3" as HTMLFormElement in the collection.

I'm still trying to learn how/where sub-frames and non-standard items are located in the IE object... I have a page I'm trying to navigate through and I can't find a "link" in IE memory that I can see on the page... if anyone has any experience with this, please jump in!

But I digress... two ways to reference to "item 2" are with
oIE.Document.forms(1) (0 indexed)
or my preferred way...
oIE.Document.forms.nameditem("TargetForm")
where
oIE.Document.forms(1).name = "TargetForm"

then to reference to an element in "TargetForm" we can use either
oIE.Document.forms(1).nameditem("InputBox")
or
oIE.Document.nameditem("TargetForm").item(3) (again, 0 indexed)

I find this way much easier than viewing the page's source, plus if you have an input box you're trying to find, you can type in "Tada!" or whatever, then check
oIE.Document.forms(1).nameditem("InputBox").value
to see if it = "Tada!" (but make sure to refresh the watch window, I think just hitting the minus then plus again will do). If so, you're in business, if not, then keep checking...

Hope it helps!

-Matt


though this does not answer my question it help understant some other things about vba... thanks for replying i guess the only way to work with java applet platforms is send keys unfortunately thats the only way i have. thank you all for your help.:beerchug: