Consulting

Results 1 to 12 of 12

Thread: Run-time error '70': Permission denied ->when i run code

  1. #1

    Run-time error '70': Permission denied ->when i run code

    I have been using this code for over a year and all of a sudden i can not run without getting the Run-time error '70': Permission denied.
    I have tried just about every thing and all the webs info on this matter that i have found has not worked.
    I have Windows 7 Ultimate. I noticed that my office 2007 completely and excel did an update back 10 days ago but i am sure i used it since then because i have had jobs to complete for the company i use this code on since then. The odd thing is that code very similar to this works for other websites on this same laptop. I have noticed some security pop up which i normally allow but i may have clicked not to once or twice, so i disabled avast security just to see, but nothing same issue. The next thing i thought maybe the owners of the Website itself changed something and now i can't fill out there forms. So i opened the code with my other laptop that is Windows vista and it runs it fine with out any issues. I googled this issue and one post looked to have promise disabling User Account Control, but that did not work either and noticing also that my vista had it activate i should have known this was not going to work. I have three similar codes for the same website that i work with, but all three have the same issue even if i have been working with only one of them in the last few days.

    On the code below if the cell "B24" were empty it would normally warn and say "Website is not opened yet", but it does not its steps threw this code and it acts as if the website url is in the "B24" cell and then tries to execute my code and it fails with the Run-time error we are now talking about. Note that it does this either with or without the "B24" cell having the URL in it.

    I also thought internet explorer is causing it and is blocking the website, but i could not find it as a blocked website or popup.
    So what could be causing this issue. Is it the code that i have not changed and always worked before, Excel program itself, security setting that i may have blocked and had nothing to do with avast security software, any suggestion welcome.

    Public Sub Subject_Click()
    
    Dim objSW As SHDocVw.ShellWindows
    Dim objIE As SHDocVw.InternetExplorer
    Dim ie As Object
    Dim bAppRunning As Boolean
    
    
    Set objSW = New SHDocVw.ShellWindows
    If objSW.Count Then 'new
      For Each ie In objSW
        If InStr(1, ie.LocationURL, Range("b24")) Then
        
          bAppRunning = True
          ie.Visible = True
          
          Do
            DoEvents
          Loop Until ie.ReadyState = 4
          
          '-----------My Code start here
          ie.Document.frames.Item("_MAIN").Document.All.Item("Owner").Value = Range("c54")
          ie.Document.frames.Item("_MAIN").Document.All.Item("APN").Value = Range("d54")
          
          '-----------My Code ends here
          Exit For
        End If
      Next ie
    End If
    If bAppRunning = False Then
      
      
      MsgBox "Website not Opened Yet"
    End If
    
    
    Set objIE = Nothing
    Set objSW = Nothing
    End Sub
    Last edited by SamT; 12-22-2014 at 11:59 AM. Reason: Formatted Code with # icon

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,730
    Location
    Without a URL and the Owner and APN strings to test, it is hard to test.

    Hopefully, you have tried Compile before a Run. If the Compile fails, I suspect it would be due to the MSIE browser object not being set in the References. You can check that as well in VBE's Tools > References.

    Tip: Now we use Code tags rather than VBA tags for posting code. Click the # icon to insert those or type them.

  3. #3
    Quote Originally Posted by Kenneth Hobs View Post
    Without a URL and the Owner and APN strings to test, it is hard to test.

    Hopefully, you have tried Compile before a Run. If the Compile fails, I suspect it would be due to the MSIE browser object not being set in the References. You can check that as well in VBE's Tools > References.

    Tip: Now we use Code tags rather than VBA tags for posting code. Click the # icon to insert those or type them.
    Compile seams not to complete, or when selected it never comes back so i can click again.

    1) I checked the references and all are the same when comparing from the computer that can run code with no issues and the none working one. so don't think it has anything to do with the references.
    2) Its as if excel can not communicate well with VBA part of itself. Because when i click the buttons i have created in excel sheet it gives this error first "Permission to use object denied" which is different from the error i initially posted here. Normally when this button was pressed it would run the code that it was linked to. I have noticed it does try to step though my code at least the first one before it fail as below
     ie.Document.frames.Item("_MAIN").Document.All.Item("Owner").Value = Range("c54")
    Also in testing the error "Run-time error '70': Permission denied" only appears when the code is directly ran in its project page and sheet location.
    3) i installed microsoft office 7 update on the vista laptop the working one and it still runs this code without a problem. So it looks like the recent update may not be the problem. I may still uninstall the update on the none working laptop since i am running out of options.

  4. #4
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,840
    Location
    Compile seems not to complete, or when selected it never comes back so i can click again.
    That means that the code compiled OK and is ready for use. The Compile Option won't return until the code as written changes.

    Type "Option Explicit." without quotes, at the top of the code page(s) and compile it again.
    Please take the time to read the Forum FAQ

  5. #5
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,802
    Location
    I am somewhat curious about this line
    [Code]If objSW.Count Then 'new[/Code]
    Is it just another "shortened" line that vba accepts these days?
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    Issue still exist even after compiling and running.
    Its as if something is keeping it from continuing. Is there a way to view the steps or process that is happening in excel while it running or why this error is triggered. Kind of like event log in excel.

  7. #7
    Quote Originally Posted by Aussiebear View Post
    I am somewhat curious about this line
    [Code]If objSW.Count Then 'new[/Code]
    Is it just another "shortened" line that vba accepts these days?
    I am not the best at answering your question as i am still newbie even if working with this for over a year ago when it comes to this i made this code work by pretty much reading between the lines and copy and pasting and editing somewhat. I still have a long ways to go.
    I obtained this code and modified to work for my use. What i can understand is that it steps through all IE pages and finds the one that is already open and copies what i have in my work sheet to the internet form page. I am just glad it works so i can do my job faster. I also kind of enjoy trying to solve my own problems. But when this fails i end up here asking the experts or someone who's had this similar problem.

  8. #8
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    3,802
    Location
    its just my colonial convict type thinking.... that an If statement needs a true or false test then the result, however in this case the If statement is "If objSW.Count", what are you testing for, "then 'new". I'm assuming that the count is less than 1, then New
    Remember To Do the Following....
    Use tags when posting code to the thread,
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,840
    Location
    If Count is 0 then
    "If Count Then" is same as "If False Then"
    but
    If Count is greater than 0, then
    "If Count then" is the same as "If True Then"

    @ cfernand74,

    It is just personal preference as to which coding style you use, but I personally find it much more understandable to use
    If objSW.Count > 0 Then
    Referring to :http://vba-corner.livejournal.com/4623.html, objSW.Count is the number of IE Windows running.

    Just to eliminate a possible source of the problem, use the fully qualified location to the ranges
    Dim Ws As Excel.Worksheet
    Set Ws = ThisWorkbook.Sheets("Sheet1") 'adjust as needed
    '
    '
    If InStr(ie.LocationURL, Ws.Range("b24")) Then
    thereafter place "Ws." before all range references

    In this code, the question posed by the first line has very little to do with the linguistic meaning of the next two lines.
       If InStr(1,  ie.LocationURL, "t") Then
          bAppRunning = True
          ie.Visible = True
    If InStr(ie.LocationURL, X) > 0 is true if X = "" or if X = "t", or "p", or "http://", etc, as long as you have at least one instance of IE running, Visible or not, unless, of course you're looking at an FTP site.

    BTW, your code runs fine for me, right up to
    ie.Document.frames.Item("_MAIN").Document.All.Item("Owner").Value = Range("c54")
    This little procedure is not very robust at all. Fortunately the code in http://vba-corner.livejournal.com/4623.html, will do what you need if you realise that "For Each ie in objSW" will loop you through all tabs in all IE windows.
    Last edited by SamT; 12-22-2014 at 05:58 PM.
    Please take the time to read the Forum FAQ

  10. #10
    All good suggestions which i will be implementing going forward, but problem persists. I am in the process of removing the office updates. But it been time consuming each has to be uninstalled individually. I still don't think this will salve my problem as i tested it by installing the update on my backup laptop that is running windows vista instead of windows 7. And Vista - office 2007 updated still ran this same code without any issues. This is my last resort i am hoping it is a windows 7 -office 2007 update issue. Will update as soon as i uninstall completely. I am thinking its not the code. Something must have happened between now and 11 days ago. Its as if there is block stopping excel from completing the code.
    Please note that this is only happening with this one website. Unfortunately to run the code you would have to log in. And i can't give access.
    I thought maybe i was blocking the website in some way but i think i have checked everything. Disabling all security does not do anything different.
    I don't want to uninstall office if i can avoid it.
    Again i have checked all my references and they are the same as my back up laptop. Also i have not personally made any reference changes for over 6 months.

  11. #11

    Issue resolved : Run-time error '70': Permission denied

    Found the problem. As i was half way through the process of uninstalling the office 2007 update. I noticed a more recent update for windows 7 on 12/19/14. I figured i would uninstall it and test the code again. Lord be hold the issue is resolved.


    The update that I uninstalled and was causing the problem is
    "Update for Internet Explorer 11 for Windows 7 for x64-based Systems(KB3025390)" 190BK.


    I don't know how i had missed it. I must have gone up and down that list several times.


    I don't know what it changed in the process of installation, but if removed issue disappears.


    Since issue is resolve i went back to windows update and reinstalled all updates for office 2007 that i just had removed. I tested code again to make sure the office 2007 updates will not cause an issues and NO issue. It is working as it should.


    Sorry for wasting peoples time by not seeing that update, but hopefully this will help the next person with this similar issue. Now i am back to work.
    Till the next issue.
    Thank you all for trying to help me and for teaching me on improving my code.

  12. #12
    Moderator VBAX Wizard SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    6,840
    Location
    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •