+ Reply to Thread
Results 1 to 5 of 5

Read folder access rights

  1. #1
    Eric van Uden
    Guest

    Read folder access rights

    Hello group,

    This has probably been answered before, bu I cannot locate the answer.
    Before opening a workbook from another workbook, I need to check if the user
    has write permission for the file.
    Then I can warn the user if opening the file to continue the procedure
    would be useless, and offer a cancel.

    Using Excel 2k and up on WinXP boxes, WinNT and Server 2k3 networking.

    Any pointers would be appreciated.

    Eric



  2. #2
    Bob Phillips
    Guest

    Re: Read folder access rights

    Eric,

    You could just open the file and check if it is open read-only

    Dim sFile As String

    sFile = "C:\myTest\volker1.xls"
    On Error GoTo file_error
    Workbooks.Open Filename:=sFile
    If ActiveWorkbook.ReadOnly = True Then
    MsgBox sFile & " is in read-only", 5, "Title", vbYesNo
    ActiveWorkbook.Close savechanges:=False
    Exit Sub
    End If

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Eric van Uden" <eric[ @ ]doornroosje[ . ]nl> wrote in message
    news:OJKmfCx2FHA.896@TK2MSFTNGP09.phx.gbl...
    > Hello group,
    >
    > This has probably been answered before, bu I cannot locate the answer.
    > Before opening a workbook from another workbook, I need to check if the

    user
    > has write permission for the file.
    > Then I can warn the user if opening the file to continue the procedure
    > would be useless, and offer a cancel.
    >
    > Using Excel 2k and up on WinXP boxes, WinNT and Server 2k3 networking.
    >
    > Any pointers would be appreciated.
    >
    > Eric
    >
    >




  3. #3
    Eric van Uden
    Guest

    Re: Read folder access rights

    Thanks Bob,

    Your answer confirms what I have gathered from miscellaneous remarks all
    over the web, that there is probably to way to 'test the water' other than
    by jumping in. Still, I am surprised that with all the shell and filsesystem
    objects and properties, and all the networking, there's no direct way of
    knowing whether the current user has rights in a folder. Maybe I should look
    into WMI rather than native Excel objects...

    For now, and for my immediate purpose, though, your solution is probably the
    way to go.

    Thanks for the acurate sample code.

    Eric


    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> schreef in bericht
    news:%23QfnpSx2FHA.1700@tk2msftngp13.phx.gbl...
    > Eric,
    >
    > You could just open the file and check if it is open read-only
    >
    > Dim sFile As String
    >
    > sFile = "C:\myTest\volker1.xls"
    > On Error GoTo file_error
    > Workbooks.Open Filename:=sFile
    > If ActiveWorkbook.ReadOnly = True Then
    > MsgBox sFile & " is in read-only", 5, "Title", vbYesNo
    > ActiveWorkbook.Close savechanges:=False
    > Exit Sub
    > End If
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Eric van Uden" <eric[ @ ]doornroosje[ . ]nl> wrote in message
    > news:OJKmfCx2FHA.896@TK2MSFTNGP09.phx.gbl...
    >> Hello group,
    >>
    >> This has probably been answered before, bu I cannot locate the answer.
    >> Before opening a workbook from another workbook, I need to check if the

    > user
    >> has write permission for the file.
    >> Then I can warn the user if opening the file to continue the procedure
    >> would be useless, and offer a cancel.
    >>
    >> Using Excel 2k and up on WinXP boxes, WinNT and Server 2k3 networking.
    >>
    >> Any pointers would be appreciated.
    >>
    >> Eric
    >>
    >>

    >
    >




  4. #4
    Bob Phillips
    Guest

    Re: Read folder access rights

    Eric,

    There probably is a way using APIs and stuff, I just gave you the way I use
    it. I will take a little look, and if I work something out I will post it
    back to you. Access rights get a bit hairy though.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Eric van Uden" <ericvanuden wanadoo nl> wrote in message
    news:eLKCs102FHA.476@TK2MSFTNGP15.phx.gbl...
    > Thanks Bob,
    >
    > Your answer confirms what I have gathered from miscellaneous remarks all
    > over the web, that there is probably to way to 'test the water' other than
    > by jumping in. Still, I am surprised that with all the shell and

    filsesystem
    > objects and properties, and all the networking, there's no direct way of
    > knowing whether the current user has rights in a folder. Maybe I should

    look
    > into WMI rather than native Excel objects...
    >
    > For now, and for my immediate purpose, though, your solution is probably

    the
    > way to go.
    >
    > Thanks for the acurate sample code.
    >
    > Eric
    >
    >
    > "Bob Phillips" <bob.phillips@notheretiscali.co.uk> schreef in bericht
    > news:%23QfnpSx2FHA.1700@tk2msftngp13.phx.gbl...
    > > Eric,
    > >
    > > You could just open the file and check if it is open read-only
    > >
    > > Dim sFile As String
    > >
    > > sFile = "C:\myTest\volker1.xls"
    > > On Error GoTo file_error
    > > Workbooks.Open Filename:=sFile
    > > If ActiveWorkbook.ReadOnly = True Then
    > > MsgBox sFile & " is in read-only", 5, "Title", vbYesNo
    > > ActiveWorkbook.Close savechanges:=False
    > > Exit Sub
    > > End If
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "Eric van Uden" <eric[ @ ]doornroosje[ . ]nl> wrote in message
    > > news:OJKmfCx2FHA.896@TK2MSFTNGP09.phx.gbl...
    > >> Hello group,
    > >>
    > >> This has probably been answered before, bu I cannot locate the answer.
    > >> Before opening a workbook from another workbook, I need to check if the

    > > user
    > >> has write permission for the file.
    > >> Then I can warn the user if opening the file to continue the procedure
    > >> would be useless, and offer a cancel.
    > >>
    > >> Using Excel 2k and up on WinXP boxes, WinNT and Server 2k3 networking.
    > >>
    > >> Any pointers would be appreciated.
    > >>
    > >> Eric
    > >>
    > >>

    > >
    > >

    >
    >




  5. #5
    Dennis
    Guest

    Re: Read folder access rights

    First, I want to thank Bob and Eric for their help!
    (Eric also posted my question)

    Secondly, I want to apologize, because I had a brainwave during the
    washing-up which led to an answer to my own question...

    Try to create something in the folder in question, e.g. a new folder.
    Here's my code:

    Function Right_to_Write_in_Folder(FolderFullName As String) As Boolean
    '(Dennis Tharmaratnam)
    Dim FSO As Object, Dummy As Object

    Set FSO = CreateObject("Scripting.FileSystemObject")
    If Right(FolderFullName, 1) <> "\" Then FolderFullName = FolderFullName &
    "\"
    On Error GoTo No_Right
    Set Dummy = FSO.CreateFolder(FolderFullName & "Dummy" & Format(Rnd *
    1000000000, "0"))
    Right_to_Write_in_Folder = True
    Dummy.Delete
    Set Dummy = Nothing
    No_Right:
    Set FSO = Nothing
    End Function

    (Assumptions: folder FolderFullName exists and the user has the right to
    read it's contents)

    I hope the answer is useful to others too.


    Kind regards,

    Dennis Tharmaratnam


    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> schreef in bericht
    news:eCEMM752FHA.2640@TK2MSFTNGP09.phx.gbl...
    > Eric,
    >
    > There probably is a way using APIs and stuff, I just gave you the way I
    > use
    > it. I will take a little look, and if I work something out I will post it
    > back to you. Access rights get a bit hairy though.
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Eric van Uden" <ericvanuden wanadoo nl> wrote in message
    > news:eLKCs102FHA.476@TK2MSFTNGP15.phx.gbl...
    >> Thanks Bob,
    >>
    >> Your answer confirms what I have gathered from miscellaneous remarks all
    >> over the web, that there is probably to way to 'test the water' other
    >> than
    >> by jumping in. Still, I am surprised that with all the shell and

    > filsesystem
    >> objects and properties, and all the networking, there's no direct way of
    >> knowing whether the current user has rights in a folder. Maybe I should

    > look
    >> into WMI rather than native Excel objects...
    >>
    >> For now, and for my immediate purpose, though, your solution is probably

    > the
    >> way to go.
    >>
    >> Thanks for the acurate sample code.
    >>
    >> Eric
    >>
    >>
    >> "Bob Phillips" <bob.phillips@notheretiscali.co.uk> schreef in bericht
    >> news:%23QfnpSx2FHA.1700@tk2msftngp13.phx.gbl...
    >> > Eric,
    >> >
    >> > You could just open the file and check if it is open read-only
    >> >
    >> > Dim sFile As String
    >> >
    >> > sFile = "C:\myTest\volker1.xls"
    >> > On Error GoTo file_error
    >> > Workbooks.Open Filename:=sFile
    >> > If ActiveWorkbook.ReadOnly = True Then
    >> > MsgBox sFile & " is in read-only", 5, "Title", vbYesNo
    >> > ActiveWorkbook.Close savechanges:=False
    >> > Exit Sub
    >> > End If
    >> >
    >> > --
    >> >
    >> > HTH
    >> >
    >> > RP
    >> > (remove nothere from the email address if mailing direct)
    >> >
    >> >
    >> > "Eric van Uden" <eric[ @ ]doornroosje[ . ]nl> wrote in message
    >> > news:OJKmfCx2FHA.896@TK2MSFTNGP09.phx.gbl...
    >> >> Hello group,
    >> >>
    >> >> This has probably been answered before, bu I cannot locate the answer.
    >> >> Before opening a workbook from another workbook, I need to check if
    >> >> the
    >> > user
    >> >> has write permission for the file.
    >> >> Then I can warn the user if opening the file to continue the
    >> >> procedure
    >> >> would be useless, and offer a cancel.
    >> >>
    >> >> Using Excel 2k and up on WinXP boxes, WinNT and Server 2k3 networking.
    >> >>
    >> >> Any pointers would be appreciated.
    >> >>
    >> >> Eric
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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