Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to use Java in Excel VBA?

Hi,
On our intranet, we have a wab page where we can type a
doc number and click on submit button. When we click on
submit button the doc no is sent to the server and server
in return sends the most recent version of that document
to the wab page.
I want to get the latest version no for series of doc nos
listed in excel file.
I succeded in opening the pageand typing the doc number
but unable to click on the submit button
programatically.The error is runtime error no 91 " object
variable or with block variable not set"
So far I have this.
Sub NEW_DOC_NO()
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
.Navigate "http://docser.gis.com/webapp/jsp/nochang
e/YourNewNumber.jsp"
Do Until Not .Busy
DoEvents
Loop
Set ipf = ie.document.all.Item("OLD_MDN")
ipf.Value = "02232601093"
Set ipf = ie.document.all.Item("button")
ipf.Value = "Submit" <<<<ERROR LINE
ipf.Click

Do Until Not .Busy
DoEvents
Loop
End With

ie.ExecWB 17, 2
ie.ExecWB 12, 0

Range("A1").Select
ActiveSheet.Paste
End Sub

The submit button uses the following two java codes.
code1

<input type="button" name="Submit" class="buttonskeen"
value=" Submit " onclick="javascript:validateData()"

code 2

{

document.Mainform.action"http://docser.gis.com/webapp/jsp/n
ochange/YourNewNumber.jsp";
document.Mainform.submit();
}

May I know whats wrong with my code?
Any help is much appreciated.
Thanks.
Sirin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default How to use Java in Excel VBA?

"Sirin" wrote in message
...
Hi,
On our intranet, we have a wab page where we can type a
doc number and click on submit button. When we click on
submit button the doc no is sent to the server and server
in return sends the most recent version of that document
to the wab page.
I want to get the latest version no for series of doc nos
listed in excel file.
I succeded in opening the pageand typing the doc number
but unable to click on the submit button
programatically.The error is runtime error no 91 " object
variable or with block variable not set"
So far I have this.
Sub NEW_DOC_NO()
Set ie = CreateObject("InternetExplorer.Application")

With ie
.Visible = True
.Navigate "http://docser.gis.com/webapp/jsp/nochang
e/YourNewNumber.jsp"
Do Until Not .Busy
DoEvents
Loop
Set ipf = ie.document.all.Item("OLD_MDN")
ipf.Value = "02232601093"
Set ipf = ie.document.all.Item("button")
ipf.Value = "Submit" <<<<ERROR LINE
ipf.Click

Do Until Not .Busy
DoEvents
Loop
End With

ie.ExecWB 17, 2
ie.ExecWB 12, 0

Range("A1").Select
ActiveSheet.Paste
End Sub

The submit button uses the following two java codes.
code1

<input type="button" name="Submit" class="buttonskeen"
value=" Submit " onclick="javascript:validateData()"

code 2

{

document.Mainform.action"http://docser.gis.com/webapp/jsp/n
ochange/YourNewNumber.jsp";
document.Mainform.submit();
}

May I know whats wrong with my code?
Any help is much appreciated.
Thanks.
Sirin


Unless your form does something very complicated I wouldn't do it this way
with IE automation but use xmlHttp request. There are lots of posts in
Google groups about this. However in your example you have two choices,
either call the button's click event or submit the form yourself:

With ie
.Visible = True
.Navigate
"http://docser.gis.com/webapp/jsp/nochange/YourNewNumber.jsp"
'Do Until Not .Busy
'DoEvents
'Loop
Do Until .readyState = 4 'Complete 'I've found this more reliable
than busy property
DoEvents
Loop
Set ipf = ie.document.all.Item("OLD_MDN")
ipf.Value = "02232601093"
Set ipf = ie.document.all.Item("button")
Call ipf.Click()
'OR instead of the above TWO lines
Call ipf.form.submit()
Do Until .readyState = 4 'Complete 'I've found this more reliable
than busy property
DoEvents
Loop
End With

ie.ExecWB 17, 2
ie.ExecWB 12, 0

Range("A1").Select
ActiveSheet.Paste
End Sub

--

Joe



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
Convert excel to java shnim1 Excel Discussion (Misc queries) 0 November 24th 05 10:56 PM
How to use Java in Excel VBA? Sirin Excel Programming 0 November 27th 04 11:52 AM
Does Excel Support Java? ZOCOR Excel Programming 3 August 31st 04 02:46 PM
Using Excel XLL in Java mikekwok[_2_] Excel Programming 0 October 11th 03 04:38 AM
Start Excel from Java E.Anderegg Excel Programming 1 July 21st 03 10:45 AM


All times are GMT +1. The time now is 03:13 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"