Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
19 Posts
0 Kudos
Registered: ‎03-27-2012
Post 1 of 3
Accepted Solution

Excel Message - Cannot find file

283 Views, 2 Replies
10-22-2012 09:51 AM

Excel Message - Cannot find file

 

I am using a lisp file that I found on a CAD forum to grab data from an excel file. I have tweeked it a little to meet my needs. The location of the excel file is hard wired into the lisp file. It is not an option for the user. However, if the user does not have access to the location where the excel file is being stored an excel error message will pop up saying that the file could not be found (see JPG file attached).

 

I need to find a way to keep this error message from popping up. I have set up the program to let the user specify the location of the file if the file is not found, but I still get this error message.

 

It would be nice if there was a way to have the program take the location specified and look to see if there is a file at that location, but not try to open the file. Then I could use some logic to decide if the location hard wired into the program should be used or if the user should specify the location. Then I'd avoid the error altogether.

 

Please help.

 

I have attached a sample lisp file and excel file that can be used to see what error message I am getting.

 

Thanks.

Try testing if your file is there by using findfile.

 

(setq IsMyFileThere  (findfile "G:\\MetaClas DataBase\\METACLAS_XREF_DATA_.xlsx"))

 

If it returns nil then it cannot find your file.

 

Then you could redirect it to the open file dialog using getfiled to let the user select a file.

 

Sorry I cant be more help than that but I have only tweaked a lisp that uses these.

 

Rick

 

 

Valued Contributor
88 Posts
10 Kudos
Registered: ‎07-25-2012
Post 2 of 3

Re: Excel Message - Cannot find file

10-22-2012 11:09 AM in reply to: nothin

Try testing if your file is there by using findfile.

 

(setq IsMyFileThere  (findfile "G:\\MetaClas DataBase\\METACLAS_XREF_DATA_.xlsx"))

 

If it returns nil then it cannot find your file.

 

Then you could redirect it to the open file dialog using getfiled to let the user select a file.

 

Sorry I cant be more help than that but I have only tweaked a lisp that uses these.

 

Rick

 

 

Contributor
19 Posts
0 Kudos
Registered: ‎03-27-2012
Post 3 of 3

Re: Excel Message - Cannot find file

10-22-2012 11:18 AM in reply to: Rick-K

Thanks! That will work.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post