Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Columns not accessible | Excel Worksheet Functions | |||
Check if a sheet exists in a file, without opening that file | Excel Programming | |||
url not accessible | Excel Programming | |||
code to check file size everytime an Excel file is opened | Excel Programming | |||
Is folder accessible? | Excel Programming |