Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Check if file Is Accessible

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Check if file Is Accessible

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.number0 then
msgbox err.description
'Do something about the error
end if

NickHK

"zimitry" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Check if file Is Accessible

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" wrote in message
:

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.number0 then
msgbox err.description
'Do something about the error
end if

NickHK

"zimitry" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Check if file Is Accessible

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" wrote in message
...
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" wrote in message
:

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.number0 then
msgbox err.description
'Do something about the error
end if

NickHK

"zimitry" wrote in message
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Check if file Is Accessible

Thanks NickHK - much appreciated your explanation
Jim

"NickHK" wrote in message
:

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" wrote in message
...
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" wrote in message
:

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.number0 then
msgbox err.description
'Do something about the error
end if

NickHK

"zimitry" wrote in message
...
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
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
Columns not accessible JayDee Excel Worksheet Functions 3 December 15th 08 09:42 PM
Check if a sheet exists in a file, without opening that file Bogdan Excel Programming 5 March 9th 07 01:46 PM
url not accessible mikeolson Excel Programming 6 March 6th 07 08:08 AM
code to check file size everytime an Excel file is opened Kaiser[_2_] Excel Programming 2 July 30th 06 05:46 PM
Is folder accessible? quartz[_2_] Excel Programming 1 September 21st 05 01:11 PM


All times are GMT +1. The time now is 05:54 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"