Excel Error 438 Object Doesn't Support property or Method

kdenney

Board Regular
Joined
Apr 26, 2010
Messages
103
I am trying to use the below code to go a specific website and cause a
dropdown to fire. But it is giving a error 438 object doesnt support this property or method at the With appIE.document.frmNavigation spot in the code. Any suggestions?


Sub PropInfo()
Dim appIE As SHDocVw.InternetExplorer
Set appIE = New SHDocVw.InternetExplorer
'Set appIE = CreateObject("INTERNETEXPLORER.APPLICATION")
appIE.Visible = True
appIE.navigate "http://gisims2.miamidade.gov/MyHome/proptext.asp"

Do While appIE.Busy: DoEvents: Loop
Do While appIE.readyState <> 4: DoEvents: Loop

With appIE.document.frmNavigation
.Item("bytool").Value = "ADDR" 'Search by' dropdown
' .Item("bytool").selectedIndex = 1 'an alternative to setting the value
directly
.Item("bytool").onchange 'should fire the event handler on the select
'etc .submit
End With
End Sub
 
This postback command actually fires an event which changes the forms represented on the page so the user can input data into those forms for instance it is a dropdown which say a user needs vin numbers. They would select vin numbers from dropdown and the form vin number would pop up and it would hide all others. I don't know why they created it this way rather than having one form for every dropdown needed but I am not the web designers. Hope that makes sense.
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
I think you got the right thing - didn't realise it wouldn't post.

Basically it's a javascript function callled _doPostBack which is apparently generated automatically.

Looks something like this.
Code:
function __doPostBack(eventTarget, eventArgument) {  
    var theform = document.myForm;  
     theform.__EVENTTARGET.value = eventTarget;  
    theform.__EVENTARGUMENT.value = eventArgument;  
    theform.submit();  
}

Here's where I found it http://www.xefteri.com/articles/show.cfm?id=18, but I've seen it on plenty of ASP pages.
 
Upvote 0
I just tried it using the below code and it bugged out at this line:

ddTool.selectedindex = 2

Option Explicit

Sub PropInfo()
Dim appIE As Object
Dim doc As Object
Dim frmNav As Object
Dim ddTool As Object
Dim btnSubmit As Object

Set appIE = CreateObject("INTERNETEXPLORER.APPLICATION")

appIE.Visible = True

appIE.navigate "Company Internet"
Do While appIE.Busy: DoEvents: Loop

Do While appIE.ReadyState <> 4: DoEvents: Loop

Set doc = appIE.document
Do While doc.ReadyState <> "complete": DoEvents: Loop
' Set frmNav = doc.getelementbyid("frmnavigation")
Set ddTool = doc.getelementbyid("ELEMENT ID")
Do While doc.ReadyState <> "complete": DoEvents: Loop
ddTool.selectedindex = 2
ddTool.onchange
Set appIE = Nothing

End Sub

Am I doing something wrong? The error is Run Time Error 91 Object Variable or With Variable Not Set. But the element ID is set properly is there anything else that might work?
 
Upvote 0
Norie,

That is the right code (HTML) for postback... what can we do to trigger it properly from the beginning or are you able to do it? Thanks!
 
Upvote 0
That code is not HTML, it's javascript.

It's used to run code on the server side of things, perhaps it's explained better in the link I posted.

As for the object variable not set etc error then without knowing more about the actual page you are working with it's hard to help.

I did kind of mention that right at the start.:)

PS 'ELEMENT ID' is a typo isn't it?
 
Upvote 0
I'll try but you have to understand that every page is different.

Not totally different but enough so that it's difficult to write generic code for this sort of thing.

I'm not trying to be difficult.:)
 
Upvote 0
The above site has a web dropdown "Thread View" and each time you change that drop down the Postback argument creates a different look for the example they are trying to help people with. The same argument applies on the site I am trying except instead of the javascript creating another example it shows another form to enter information into which is the form I am trying to get to. Thanks beforehand.
 
Upvote 0
I'll take a look, but I don't think you quite understand how postback works.

The way I understand it is that there is some code on the server which is getting executed when the postback is triggered.

Unless you actually have access to the server you'll probably never see the code that's actually being run 'behind the scenes'.

Anyway, I wasn't sure what you wanted me to show/try with the URL you posted but this code changes the dropdown to treeview and then triggers/runs the onchange.
Rich (BB code):
Option Explicit
 
Sub PropInfo()
Dim appIE As Object
Dim doc As Object
Dim frmNav As Object
Dim ddTool As Object
Dim btnSubmit As Object
 
    Set appIE = CreateObject("INTERNETEXPLORER.APPLICATION")
 
    appIE.Visible = True
 
    appIE.navigate "http://www.dotnetmonster.com/Uwe/Th...ropDownLists-AutoPostBack-and-the-back-button"
 
    Do While appIE.Busy: DoEvents: Loop
 
    Do While appIE.ReadyState <> 4: DoEvents: Loop
 
    Set doc = appIE.document
 
    Do While doc.ReadyState <> "complete": DoEvents: Loop
 
    Set ddTool = doc.getelementbyid("ctl00_ctl00_MainPlaceHolder_viewList")
 
    ddTool.selectedindex = 0
 
    ddTool.onchange

    Do While doc.ReadyState <> "complete": DoEvents: Loop

    Set appIE = Nothing
 
End Sub
By the way this code is 'quick and nasty' - I've tried to declare all the variables etc but with this sort of thing sometimes you can't think that far ahead...

If that makes any sense.:)

PS I've actually seen people asking for help with code that worked previously but didn't work now.

The code was fine - if the page had stayed the same, but like most things on the web it hadn't.:eek:
 
Upvote 0

Forum statistics

Threads
1,225,553
Messages
6,185,623
Members
453,309
Latest member
window15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top