+ Reply to Thread
Results 1 to 2 of 2

skip folders with no permission in folder mapping

  1. #1
    Registered User
    Join Date
    04-01-2016
    Location
    Israel
    MS-Off Ver
    2016
    Posts
    1

    Question skip folders with no permission in folder mapping

    Hello,
    i have a code that i found online and modified it a little for my needs. the code is mappig folder and subfolder in a spesific path.

    when it comes to a fold with no view permission its stoped.

    can anyone help me with modifiing the code so it will map the folder name and move on to the next?

    Thank you

    Global startFolderPath As String

    Public Sub Hierarchical_Folders_and_Files_Listing2()

    Dim startFolderPath As String
    Dim startCell As Range
    Dim n As Long

    startFolderPath = Sheet1.Cells(3, 6)

    With Sheets("Sheet1")
    ActiveSheet.Range("A1:D5000").Value = Delete
    .Activate
    Set startCell = .Range("A1")
    End With

    n = List_Folders_and_Files2(startFolderPath, startCell)

    End Sub


    Private Function List_Folders_and_Files2(folderPath As String, destCell As Range) As Long

    Static FSO As Object
    Dim thisFolder As Object, subfolder As Object
    Dim fileItem As Object
    Dim n As Long

    If FSO Is Nothing Then Set FSO = CreateObject("Scripting.FileSystemObject")

    Set thisFolder = FSO.GetFolder(folderPath)



    'Add hyperlink for this folder

    destCell.Parent.Hyperlinks.Add Anchor:=destCell, Address:=thisFolder.Path, TextToDisplay:=thisFolder.Name

    'List subfolders in this folder
    If destCell.Column > Sheet1.Cells(4, 6) Then GoTo here

    n = 0


    For Each subfolder In thisFolder.SubFolders

    n = n + 1 + List_Folders_and_Files2(subfolder.Path, destCell.Offset(n + 1, 1))

    Next

    here:

    'Add hyperlink for each file in this folder

    List_Folders_and_Files2 = n


    End Function

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: skip folders with no permission in folder mapping

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    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



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

+ 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. [SOLVED] Creating Sub-Folders & Setting Permission
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2015, 02:42 AM
  2. Try opening a file from a folder without permission
    By crasy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-16-2015, 07:48 AM
  3. [SOLVED] Count only the current folders in a folder, skip hidden & system folders
    By CobraLAD in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-03-2015, 04:58 AM
  4. Create FOLDER in subfoldesr and move folders with specific names into FOLDER
    By Amarjeet Singh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-25-2015, 09:46 AM
  5. Folder Permission
    By my_fair_share in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-08-2010, 12:43 PM
  6. Folder permission Issues
    By champs in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 06-09-2009, 07:26 AM
  7. Replies: 2
    Last Post: 05-07-2006, 03:20 PM

Tags for this Thread

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