Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default permission denied error when automating explorer

Hi,
I have some code that navigates to a website, and places certain links
into a collection. I then try a for each loop through the collection
to navigate to those links. If I just let it run, I get a permission
denied error, but if I pause at the for each line and step through,
everything works okay. Can anybody tell me whats going on? I've done
this kind of thing many times and never had this problem.

Thanks,
Rob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default permission denied error when automating explorer

Probably all the data isn't available. Database acces or switching pages
takes time and you sometimes have to wait for the page to be ready before you
proceeed.

The code below works when you are naviagating but will not always work

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState < 4
DoEvents
Loop

Hee is an example where I had to wait for an object to be available before
the code could continue.

but.Select
but.Click

On Error Resume Next ' Defer error handling.
Do
Err.Clear
Set PageNumber = IE.document.getElementById("pageNumber")
Pages = PageNumber.Value
DoEvents
Loop While Err.Number < 0
On Error GoTo 0


"festdaddy" wrote:

Hi,
I have some code that navigates to a website, and places certain links
into a collection. I then try a for each loop through the collection
to navigate to those links. If I just let it run, I get a permission
denied error, but if I pause at the for each line and step through,
everything works okay. Can anybody tell me whats going on? I've done
this kind of thing many times and never had this problem.

Thanks,
Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default permission denied error when automating explorer

Thanks for responding Joel.

I'm pretty sure that isn't the problem because the collection is
getting filled okay, its when i try to access a member of the
collection and do something with it. I can write each link to a cell,
and access it that way (but that isn't desirable in this case), so it
seems to be some sort of issue with links and collections? I don't
understand why it works if I pause first.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default permission denied error when automating explorer

At full operating speed you can't tell "when" the object is getting filled.
It may take a half a second to fill the object but the macro is running very
fast and will get to the object before it is filled. When you step through
the code the object gets filled before you require the object.

"festdaddy" wrote:

Thanks for responding Joel.

I'm pretty sure that isn't the problem because the collection is
getting filled okay, its when i try to access a member of the
collection and do something with it. I can write each link to a cell,
and access it that way (but that isn't desirable in this case), so it
seems to be some sort of issue with links and collections? I don't
understand why it works if I pause first.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default permission denied error when automating explorer

Yes, I understand that. I've tried waiting several different ways, and
it doesn't seem to matter. here's the code:

Sub get_data_from_site()

Dim ie As SHDocVw.InternetExplorer
Dim catone As Object
Dim cattwo As Object
Dim catthree As Object
Dim trims As New Collection

nrw = 1
Set ie = New SHDocVw.InternetExplorer

'goto main site for new cars
ie.Navigate "http://www.mysite.com"
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend
Set catone= ie.document

'If I pause here, everything works fine. If I let it run, I get
permission denied, with the If line highlighted. Waiting doesn't seem
to help.
For Each lma In catone.Links
If InStr(1, lma, "condition1") Then
ie.Navigate lma
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend
Set cattwo= ie.document

For Each lmo In cattwo.Links
If InStr(1, lmo, "condition2") Then
ie.Navigate lmo
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend

Set catthree= ie.document

For Each lt In catthree.Links
If InStr(1, lt, "condition3") Then
On Error Resume Next
la = Array(lt, lt.sourceIndex)
trims.Add la, lt
On Error GoTo 0
End If
Next lt

Sheets("test").Activate

For x = 1 To trims.Count
'Cells(nrw, 1) = cat1
'Cells(nrw, 2) = cat2
c = 3

For y = trims(x)(1) To trims(x + 1)(1)
Cells(nrw, c) =
trimsdoc.all.item(y).innerText
c = c + 1
Next y
nrw = nrw + 1
Next x
End If
Next lmo
End If
Next lma
ie.Quit
Set ie = Nothing

End Sub


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default permission denied error when automating explorer

This is how I run my code. Change opening IE and made ready state 4.


Sub get_data_from_site()

'Dim ie As SHDocVw.InternetExplorer
Dim catone As Object
Dim cattwo As Object
Dim catthree As Object
Dim trims As New Collection

nrw = 1
Set ie = CreateObject("InternetExplorer.application")
ie.Application.Visible = True
'goto main site for new cars
ie.Navigate "http://www.mysite.com"
While ie.readyState < 4
DoEvents
Wend
Set catone = ie.document

'If I pause here, everything works fine. If I let it run, I get
'permission denied, with the If line highlighted. Waiting doesn't seem
'to help.
For Each lma In catone.Links
If InStr(1, lma, "condition1") Then
ie.Navigate lma
While ie.readyState < 4
DoEvents
Wend
Set cattwo = ie.document

For Each lmo In cattwo.Links
If InStr(1, lmo, "condition2") Then
ie.Navigate lmo
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend

Set catthree = ie.document

For Each lt In catthree.Links
If InStr(1, lt, "condition3") Then
On Error Resume Next
la = Array(lt, lt.sourceIndex)
trims.Add la, lt
On Error GoTo 0
End If
Next lt

Sheets("test").Activate

For x = 1 To trims.Count
'Cells(nrw, 1) = cat1
'Cells(nrw, 2) = cat2
c = 3

For y = trims(x)(1) To trims(x + 1)(1)
Cells(nrw, c) = trimsdoc.all.Item(y).innerText
c = c + 1
Next y
nrw = nrw + 1
Next x
End If
Next lmo
End If
Next lma
ie.Quit
Set ie = Nothing

End Sub


"festdaddy" wrote:

Yes, I understand that. I've tried waiting several different ways, and
it doesn't seem to matter. here's the code:

Sub get_data_from_site()

Dim ie As SHDocVw.InternetExplorer
Dim catone As Object
Dim cattwo As Object
Dim catthree As Object
Dim trims As New Collection

nrw = 1
Set ie = New SHDocVw.InternetExplorer

'goto main site for new cars
ie.Navigate "http://www.mysite.com"
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend
Set catone= ie.document

'If I pause here, everything works fine. If I let it run, I get
permission denied, with the If line highlighted. Waiting doesn't seem
to help.
For Each lma In catone.Links
If InStr(1, lma, "condition1") Then
ie.Navigate lma
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend
Set cattwo= ie.document

For Each lmo In cattwo.Links
If InStr(1, lmo, "condition2") Then
ie.Navigate lmo
While ie.readyState < READYSTATE_COMPLETE
DoEvents
Wend

Set catthree= ie.document

For Each lt In catthree.Links
If InStr(1, lt, "condition3") Then
On Error Resume Next
la = Array(lt, lt.sourceIndex)
trims.Add la, lt
On Error GoTo 0
End If
Next lt

Sheets("test").Activate

For x = 1 To trims.Count
'Cells(nrw, 1) = cat1
'Cells(nrw, 2) = cat2
c = 3

For y = trims(x)(1) To trims(x + 1)(1)
Cells(nrw, c) =
trimsdoc.all.item(y).innerText
c = c + 1
Next y
nrw = nrw + 1
Next x
End If
Next lmo
End If
Next lma
ie.Quit
Set ie = Nothing

End Sub

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
error 70 - Permission denied MT Excel Programming 1 May 8th 05 07:20 AM
Run-time error '70': Permission denied Maury Markowitz Excel Programming 0 January 12th 05 08:31 PM
Run time error 70 permission denied Sachin[_4_] Excel Programming 0 August 21st 04 05:07 AM
Permission Denied Error 70 Tom Ogilvy Excel Programming 0 August 3rd 04 04:56 PM
Error Msg: Permission to use object denied A. Nguyen Excel Programming 4 July 14th 03 09:05 PM


All times are GMT +1. The time now is 11:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"