PDA

View Full Version : Forms in Frames Work-around



TechTalk
11-04-2008, 07:54 PM
I have a dilemma. I have created a code that works on my home PC, but not on my work PC. How can I modify the below code to select a form option within a frame such that I do not receive an "Access Denied" error. Please note that I only receive this error when trying to access the frame from my work PC, meaning I can perfom the same form select operation if I open that same form wihout the frame. My code is as follows


Set objIE = New InternetExplorer
objIE.Navigate "C:\Documents and Settings\Desktop\page.htm"
objIE.Visible = True
Do Until objIE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
For Each ieForm In objIE.Document.frames("Top").Document.forms
ieForm(0).Value = "BestChoice"
Exit For
Next

What other method can I use to choose a selection from the dropdown list within the frame without getting an "Access Denied" error? There has to be a workaround as this seems like a fairly simple operation.:motz2:

Demosthine
11-06-2008, 12:48 PM
Good Afternoon.

There a few things to consider as I don't have a copy of your pages.

- Where exactly does it error at your Work PC?
- Is it possibly an issue with the location of your Page.Htm file at work? Usually, in a work environment, you will have a sub-folder in Documents and Settings that represents your Username:
C:\Documents and Settings\RogerJ\Desktop
- Are you running different versions of Internet Explorer between Home and Work?
- Did your Company block certain access to pages? There are a lot of different permissions a Company can restrict and that may be part of the problem.

Take Care.
Scott

TechTalk
11-08-2008, 11:52 AM
Hi Scott,
It errors on "For Each ieForm In objIE.Document.frames("Top").Document.forms". The location opens fine both at work and home, plus I have a lot more code to this macro, including a login script, that works fine on the same page (since the login page doesn't have frames). The code also works on other pages within the site that does not have frames (by modifying the "For" script to "For Each ieForm In objIE.Document.forms". I'm not certain as to the IE versions at work, but I'm just assuming it would be different than home. In terms of the company restricting the page, it is an Intranet page, just saved to my desktop temporarily to isolate the problem as it fails both on my desktop and the Intranet at work (but as mentioned when that saved page is brought home, the above script works fine). Very frusturating, since I know the script is good. I checked my permisions for IE at work and I only have read/execute access, so I'm assuming this is where the problem stems, but it's weird that it just happens with frames. Do you think there is a workaround? Oh, and I opened up just that frame that has the dropdown in IE and the "For Each ieForm In objIE.Document.forms" then works fine. So I can select the dropdown option as long as it is not in a frame. Are there other methods of calling that frame that would work?

Demosthine
11-08-2008, 07:36 PM
Good Evening.

I'm at a complete loss here. The only thing I can come up with is that you are running IE6 at work and IE7 at home. Since I don't have IE6 at home, I'll take it to work with me on Tuesday and try it there.

I threw together an example based on what you have here and everything worked beautifully. Just FYI, I have Windows Vista with IE7.

I'm really curious to hear what the problem is if you figure it out.
Sorry I couldn't be of more help.
Scott