+ Reply to Thread
Results 1 to 3 of 3

permission denied error

Hybrid View

  1. #1
    Registered User
    Join Date
    05-17-2022
    Location
    Cleveland, Ohio
    MS-Off Ver
    Office 365
    Posts
    1

    permission denied error

    The macro below runs for the first index but gives permission denied (error code 70) in the next index. As can be seen, I have tried a lot of suggestions to grant those permissions but I keep getting the error.

    Sub Macro1()
    '
    ' Macro1 Macro
    '
    
    '
    Dim myPath As String
    Dim myName As String
    Dim fullname As String
    Dim i As Long
    Dim filelist() As Variant
    Dim shapeChart As Chart
    Dim mysheet As Worksheet
    
    myPath = "/Volumes/MyPassport/parameter_studies/roughness/GlennIce_nml/outputs/"
    fullname = myPath & "pictures"
    ReDim filelist(0)
    filelist(0) = fullname
    fileAccessGranted = GrantAccessToMultipleFiles(filelist)
    For i = 2 To 97
        Workbooks("large_and_glaze_adjusted_clean.xlsx").Activate
        myName = Cells(i, 1)
        fullname = myPath & myName & "/" & myName & "_plots.xlsx"
        Application.AskToUpdateLinks = False
        Application.DisplayAlerts = False
        Workbooks.Open filename:=fullname
        Workbooks(myName & "_plots.xlsx").Activate
        Sheets("shape_plot").Select
     
        Set shapeChart = Charts("shape_plot")
        fullname = myPath & "pictures/" & myName & ".png"
    
        On Error Resume Next
        Kill fullname
        On Error GoTo 0
    
        shapeChart.Export filename:=fullname
        Set shapeChart = Nothing
        Application.DisplayAlerts = False
        ActiveWindow.Close
    Next i
    End Sub
    Last edited by AliGW; 05-17-2022 at 01:14 PM. Reason: Code tags added.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,310

    Re: permission denied error

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code] [/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I have done it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,310

    Re: permission denied error

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new here, I shall do it for you this time: https://www.mrexcel.com/board/thread...error.1204855/)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Run-time error '70' - Permission Denied
    By FabianoGaiga in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-06-2021, 12:37 PM
  2. How to fix runtime error 70 permission denied ?
    By TR16238 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-05-2017, 02:13 AM
  3. Run-time Error '70': Permission Denied
    By phiko73 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-12-2016, 01:27 AM
  4. Run-time error '70': Permission denied
    By Arvin.Amaro in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-09-2015, 08:24 AM
  5. RunTime 70 Error - Permission Denied
    By ross88guy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-27-2011, 04:46 AM
  6. [SOLVED] error 70 - Permission denied
    By MT in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-08-2005, 03:06 AM
  7. Run-time error '70': Permission denied
    By Maury Markowitz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-12-2005, 05:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1