Need Help Pls - What's wrong with this?

D

DW

would someone pls help? am kinda lost.....don't know what is wrong. webpage
loads ok, but then it seems readystate is continuous loop. Not sure.

Don

Code:

Sub tabIE()

Dim objIE As Object
Dim response As String
msg = "How many items are you checking?"
response = InputBox(msg)
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "http://www.smcorp.com"
.resizable = True
End With
Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

Set oForm = objIE.Documents.Forms
oForm("shopper_memno").Value = "USERID" 'userid and password changed to
protect the innocent.
oForm("shopper_password").Value = "USRPSWD"
oForm("submit1").Click
Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

Call tabIE2(response)
ActiveWorkbook.Save

Set oForm = Nothing
Set objIE = Nothing
End Sub
 
J

Joel

I found some error while stepping through the code. Made some changes.
Can't go completely through code because I dont have permission to write.


Sub tabIE()

Dim objIE As Object
Dim response As String
msg = "How many items are you checking?"
response = InputBox(msg)
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "http://www.smcorp.com"
.resizable = True
End With
Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

Set oForm = objIE.Document.Forms 'changed from douments
For Each myform In oForm.Item
Select Case myform.Name

Case "shopper_memno"
oForm("shopper_memno").Value = _
"USERID" 'userid and password changed to protect the innocent.
Case "shopper_password"
oForm("shopper_password").Value = "USRPSWD"
Case "submit1"
oForm("submit1").Click
End Select
Next myform

Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

'Call tabIE2(response)
ActiveWorkbook.Save

Set oForm = Nothing
Set objIE = Nothing
End Sub
 
D

DW

Joel,
Ok, I see you've changed the "oForm" to a For Each and a Case
Statement.....why is that?

Don
 
J

Joel

When I fix these type problems I single step through the code and add
variables to the watch window. The code you had wasn't finding these items.
They were listed as items. I couldn't get VBA to recognize the names so this
was an easy way of getting around the problem. There is probably a better
way of doing this. I haven't found it
 
J

Joel

I made a couple more changes and got it to run completely through the code.

Sub tabIE()

Dim objIE As Object
Dim response As String
msg = "How many items are you checking?"
response = InputBox(msg)
Set objIE = CreateObject("InternetExplorer.Application")
With objIE
.Visible = True
.Navigate "http://www.smcorp.com"
.resizable = True
End With
Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

Set oForm = objIE.Document.Forms 'changed from douments
For Each myForm In oForm.Item
Select Case myForm.Name

Case "shopper_memno"
myForm.Value = _
"USERID" 'userid and password changed to protect the innocent.
Case "shopper_password"
myForm.Value = "USRPSWD"
Case "submit1"
myForm.Click
End Select
Next myForm

Do
DoEvents
Loop While objIE.busy
Do
DoEvents
Loop Until objIE.ReadyState = 4

'Call tabIE2(response)
ActiveWorkbook.Save

Set oForm = Nothing
Set objIE = Nothing
End Sub
 
E

Edgar

Hi
A Question, How can I see the methods and properties of an ie Object, just
like you showed before?
Cause I need to save a webpage as a workbook and i find the ie object
suitable for the login information. But I don't see any file in Excel
reference library to add.
Thank you
 
J

Joel

It has been a while since I worked your problem. It too me a lot of trials
and errors before I got the answer. There is very little documentation to
help with these three problems.

1) Right click on the VBA editor window and select OBJECT BROWSER. You can
do searches to find which properties are associated with different objects.

2) Step through code and add objects to the watch window. then look at the
properties with the objects. In your case I added oForm to the watch.

3) Use the "for each" to get items. Your problem is similar to problems
I've had with Shapes. The Shapes are indexed but your can't find them by the
shape.name. There is a count number (number of shapes on a worksheet) and
you can use and index number similar to worksheets (sheet(1),sheet(2)). Or
you can use for each myshape in worksheets.shape.

I found by adding the oform to the watch the names you where looking for was
indexed as items 1, 2, and 3. But couldn't get VBA to recognized the name.
I then used the method I used when I have problems finding shapes.name. I've
also used this method on charts when I need to get the different series on
the chart. I don't like using index I prefer to use the name of the series.
the code is more readable.

Again your problem was similar to other problems I've seen with getting a
..name of objests.
 
E

Edgar

Thanks for the suggestion. I'll start trying it rigth now.
I've found it difficult to get information about inet.chm, the file that
deploys properties ,methods and classes for managment the ie object, I spent
most of the day yesterday trying to find documentation about it. Very few,
isolated and with poor examples.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top