0

I'm trying to set a final target frame in one line, but somehow IE.Document works only if it's assigned to a variable.

So the following statement works:

Set IEDoc = IE.Document
Set objFrameMain = IEDoc.frames("frame_name")

while this one fails with Automation error:

Set objFrameMain = IE.Document.frames("frame_name")

Why could it be so?

Andrey Belykh
  • 2,234
  • 3
  • 28
  • 42
laooglee
  • 127
  • 10
  • If you're working on an intra-net (which I guess it's the case since you're not sharing a reproducible test case), I recently had a [similar experience](https://stackoverflow.com/questions/45793222/internetexplorer-application-object-raises-an-automation-error-unknown-interf/45819435#45819435). Maybe you're being able to set `objFrameMain`, but I guess it's `Nothing` and not really what you want. Try to use the type `InternetExplorerMedium` instead of `InternetExplorer` and check if it solves it, but the error you describe above doesn't make much sense to me. – Matteo NNZ Aug 24 '17 at 21:44
  • @MatteoNNZ, i don't think that it makes any difference whether he is on intranet. if the first two lines work, then the single line should work also. ...... wait a minute .... maybe it is the execution time that makes a difference – jsotola Aug 24 '17 at 22:34
  • do you have a _loop while IE busy_? – jsotola Aug 24 '17 at 22:35
  • @jsotola well it doesn't work even in step by step pace in debug mode. – laooglee Aug 24 '17 at 22:55
  • add `IE.Document.frames` into the _Watch window_ ... just highlight it and drag to _Watch window_ .... put a breakpoint at `Set IEDoc = IE.Document` and run. ... examine the `IE.Document.frames` object in _Watch window_ ... is it still _Nothing_ ? – jsotola Aug 25 '17 at 01:10
  • see if this throws an error `Debug.Print IE.Document.frames.Length` – jsotola Aug 25 '17 at 01:39
  • @jsotola that's what I thought too, but it's not the case. Intranet servers stops providing information to the browser in a different way than public websites, with the consequence that the interface becomes unknown in the IE object itself very easily when you're on an intranet. – Matteo NNZ Aug 25 '17 at 07:44
  • @MatteoNNZ, well, thanks to addressing my problem, I choose to proceed with addressing the frame after addressing IE.Doc, setting it to variable one by one. Though i'm still confused, why nested syntax (IE.Document.Frame('x').Document) doesn't work. – laooglee Sep 07 '17 at 12:23
  • @jsotola, same for you. Thanks! – laooglee Sep 07 '17 at 12:23

0 Answers0