PC Review


Reply
Thread Tools Rate Thread

Check if file Is Accessible

 
 
=?Utf-8?B?emltaXRyeQ==?=
Guest
Posts: n/a
 
      2nd Apr 2007
Hi

i'm looking to improve my excel macro's... i've have a few macros that
require other xls/csv files to be opened... my question is. How do i check if
the user has access to the required folder? I would like a message box
Specifically for the Folder is not accessible call IS to lift Restriction
etc...

my guess is some sort of DLL file is required but i'm unsure

any help would be much appreciated...

z
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      2nd Apr 2007
You can try to open the file and check for an error. Check out the help for
"On Error". Here's one way:

dim WB as workbook

On Error Resume Next
set wb=workbooks.Open(<pathandfilename>)

If err.number>0 then
msgbox err.description
'Do something about the error
end if

NickHK

"zimitry" <(E-Mail Removed)> wrote in message
news:2549DF08-00F5-4188-AB4F-(E-Mail Removed)...
> Hi
>
> i'm looking to improve my excel macro's... i've have a few macros that
> require other xls/csv files to be opened... my question is. How do i check

if
> the user has access to the required folder? I would like a message box
> Specifically for the Folder is not accessible call IS to lift Restriction
> etc...
>
> my guess is some sort of DLL file is required but i'm unsure
>
> any help would be much appreciated...
>
> z



 
Reply With Quote
 
JMay
Guest
Posts: n/a
 
      2nd Apr 2007
Nick:

2 Questions;
OP was interested in seeing if a Folder was accessible,
but I see you used pathandfilename <<filename?? Is that OK?

Also your line "On Error Resume Next" says to me
that if Excel when asked to set WB = something it can't find it..
Then IGNORE the error and continue on. Perhaps (in the background
though) an err is generated and it is your If stat which is jumping in
to
Provide the message. Is this the case?

Thanks,

Jim

"NickHK" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed):

> You can try to open the file and check for an error. Check out the help for
> "On Error". Here's one way:
>
> dim WB as workbook
>
> On Error Resume Next
> set wb=workbooks.Open(<pathandfilename>)
>
> If err.number>0 then
> msgbox err.description
> 'Do something about the error
> end if
>
> NickHK
>
> "zimitry" <(E-Mail Removed)> wrote in message
> news:2549DF08-00F5-4188-AB4F-(E-Mail Removed)...
> > Hi
> >
> > i'm looking to improve my excel macro's... i've have a few macros that
> > require other xls/csv files to be opened... my question is. How do i check

> if
> > the user has access to the required folder? I would like a message box
> > Specifically for the Folder is not accessible call IS to lift Restriction
> > etc...
> >
> > my guess is some sort of DLL file is required but i'm unsure
> >
> > any help would be much appreciated...
> >
> > z


 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      3rd Apr 2007
Jim,
Well, the OP stated "that require other xls/csv files to be opened". Just
seemed easier to attempt the main aim of the code (opening files) rather
than an inferior aim (testing for access). Without the access you cannot
open, but even with access it does not necessarily mean you can open.

If you do handle the (potential) error in some way, the code will crash.
Like this, we first check if there was actually an error and if so do
something about it, possibly abort.

NickHK

"JMay" <(E-Mail Removed)> wrote in message
news:in6Qh.309911$(E-Mail Removed)...
> Nick:
>
> 2 Questions;
> OP was interested in seeing if a Folder was accessible,
> but I see you used pathandfilename <<filename?? Is that OK?
>
> Also your line "On Error Resume Next" says to me
> that if Excel when asked to set WB = something it can't find it..
> Then IGNORE the error and continue on. Perhaps (in the background
> though) an err is generated and it is your If stat which is jumping in
> to
> Provide the message. Is this the case?
>
> Thanks,
>
> Jim
>
> "NickHK" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed):
>
> > You can try to open the file and check for an error. Check out the help

for
> > "On Error". Here's one way:
> >
> > dim WB as workbook
> >
> > On Error Resume Next
> > set wb=workbooks.Open(<pathandfilename>)
> >
> > If err.number>0 then
> > msgbox err.description
> > 'Do something about the error
> > end if
> >
> > NickHK
> >
> > "zimitry" <(E-Mail Removed)> wrote in message
> > news:2549DF08-00F5-4188-AB4F-(E-Mail Removed)...
> > > Hi
> > >
> > > i'm looking to improve my excel macro's... i've have a few macros that
> > > require other xls/csv files to be opened... my question is. How do i

check
> > if
> > > the user has access to the required folder? I would like a message

box
> > > Specifically for the Folder is not accessible call IS to lift

Restriction
> > > etc...
> > >
> > > my guess is some sort of DLL file is required but i'm unsure
> > >
> > > any help would be much appreciated...
> > >
> > > z

>



 
Reply With Quote
 
JMay
Guest
Posts: n/a
 
      3rd Apr 2007
Thanks NickHK - much appreciated your explanation
Jim

"NickHK" <(E-Mail Removed)> wrote in message
news:#3lt6$(E-Mail Removed):

> Jim,
> Well, the OP stated "that require other xls/csv files to be opened". Just
> seemed easier to attempt the main aim of the code (opening files) rather
> than an inferior aim (testing for access). Without the access you cannot
> open, but even with access it does not necessarily mean you can open.
>
> If you do handle the (potential) error in some way, the code will crash.
> Like this, we first check if there was actually an error and if so do
> something about it, possibly abort.
>
> NickHK
>
> "JMay" <(E-Mail Removed)> wrote in message
> news:in6Qh.309911$(E-Mail Removed)...
> > Nick:
> >
> > 2 Questions;
> > OP was interested in seeing if a Folder was accessible,
> > but I see you used pathandfilename <<filename?? Is that OK?
> >
> > Also your line "On Error Resume Next" says to me
> > that if Excel when asked to set WB = something it can't find it..
> > Then IGNORE the error and continue on. Perhaps (in the background
> > though) an err is generated and it is your If stat which is jumping in
> > to
> > Provide the message. Is this the case?
> >
> > Thanks,
> >
> > Jim
> >
> > "NickHK" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed):
> >
> > > You can try to open the file and check for an error. Check out the help

> for
> > > "On Error". Here's one way:
> > >
> > > dim WB as workbook
> > >
> > > On Error Resume Next
> > > set wb=workbooks.Open(<pathandfilename>)
> > >
> > > If err.number>0 then
> > > msgbox err.description
> > > 'Do something about the error
> > > end if
> > >
> > > NickHK
> > >
> > > "zimitry" <(E-Mail Removed)> wrote in message
> > > news:2549DF08-00F5-4188-AB4F-(E-Mail Removed)...
> > > > Hi
> > > >
> > > > i'm looking to improve my excel macro's... i've have a few macros that
> > > > require other xls/csv files to be opened... my question is. How do i

> check
> > > if
> > > > the user has access to the required folder? I would like a message

> box
> > > > Specifically for the Folder is not accessible call IS to lift

> Restriction
> > > > etc...
> > > >
> > > > my guess is some sort of DLL file is required but i'm unsure
> > > >
> > > > any help would be much appreciated...
> > > >
> > > > z

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
my outlook.pst file is not accessible Vivek Hutheesing Microsoft Outlook Discussion 2 11th Dec 2008 09:51 AM
File Sharing - Is not accessible =?Utf-8?B?WFAgTm92aWNl?= Windows XP Basics 0 18th Apr 2005 07:03 PM
File not accessible Doug Windows XP General 2 3rd Aug 2004 05:49 AM
File is not accessible. Nater Microsoft Windows 2000 1 23rd Dec 2003 01:02 AM
How to check if USB ports (environment) available and accessible ?? Mark Spitzer Microsoft Windows 2000 4 2nd Dec 2003 02:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 AM.