Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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" schreef in bericht
...
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
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
...
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" schreef in bericht
...
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
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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" schreef in bericht
...
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
...
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" schreef in bericht
...
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
...
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
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
Query from Access into Excel cause Access to go to read only T Stephens Excel Discussion (Misc queries) 0 March 24th 09 04:17 PM
VLOOKUP with restricted access rights DaveO[_2_] Excel Worksheet Functions 2 August 6th 07 08:20 PM
How do I unrestrict access to files Information Rights Mgmnt? Phaedrus Excel Discussion (Misc queries) 0 July 10th 05 07:41 PM
Access Rights & Reports John F.M. Excel Worksheet Functions 1 May 31st 05 09:54 PM
Shared Workbook - Defining Access Rights gizmo Excel Worksheet Functions 0 January 13th 05 04:10 PM


All times are GMT +1. The time now is 05:35 PM.

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

About Us

"It's about Microsoft Excel"