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
>
|