Solved

How to avoid this error message?

Posted on 2000-05-12
8
199 Views
Last Modified: 2013-12-18
Hi,
I have a scripts library doing report generation based on information from a Excel file.

But I want to make sure that the Excel file is in the user's local drive before I proceed to generate the reports.

I get this following error message if the Excel file is not in the local drive:

"C:\mcs_data.xls" could not be found. Check the spelling of the file name. and verify that the file location is correct.
If you are trying to open the file from the list of most recently used files on the File menu, make sure that the file has not been renamed, moved, or deleted.


Anybody knows how to skip this error message and proceed to the rest of coding, if the file is not found?

Pls help me if you knows, it's quite urgent to me....
Thanks a lot.
0
Comment
Question by:kspuea
  • 4
  • 3
8 Comments
 
LVL 5

Expert Comment

by:snocross
ID: 2804622
Can you post your code?
0
 

Author Comment

by:kspuea
ID: 2809063
Here is my coding:

Dim myExcel As Variant, myExcel1 As Variant, myExcel2 As Variant
Dim filename As String, filename1 As String, filename2 As String, shName As String
Dim aKeys (1 To 2) As String, docTAno As String
Dim item As NotesItem
     
Set db = sess.CurrentDatabase
varMth = Month(Today) - 1
varYear = Trim$(Str$(Year(Today)))
Gosub ReportDate
     
filename = "C:\mcs_data.xls"
Set myExcel = GetObject(filename, "Excel.Sheet")
-->I get an error at the above line if my excel file is not there.

Any ways to avoid the error message?

Thanks for your help, snocross!
0
 
LVL 5

Expert Comment

by:snocross
ID: 2810801
Try looking at DIR$.  I haven't done it but it looks like you can use DIR$ to retreive a list of files and check to see if it exists before you execute against the filename.
0
 

Expert Comment

by:andyDale
ID: 2812508
the other option would be to use error handling calls....

run through your code once and let the error come up. Make a note of the error number.

In your code, at the top, add:
   On Error Goto err_hand

Now at the very bottom of the code do the following:

the_end:
  Exit Sub

err_hand:
  if err() = YOUR_ERR_NUMBER Then
    ' print a specific error message
    MsgBox("Incorrect file name ....")
    Resume the_end
  else
    'print a generic error message
    MsgBox("Error "+cstr(err())+ " - "+Error(), ,"Error")
    Resume the_end
  end if
End Sub

Instead of just putting out messages you could have a routine that smartly finds the xls file, opens it and then the line:
  Resume Next
starts execution of your code back where you errered out from.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:kspuea
ID: 2812833
andyDale, it doesn't have any error number associated. The error is actually invoked by MS Excel, not by Lotus Notes.

snocross, can you provide a sample coding of your ideas?
0
 
LVL 5

Accepted Solution

by:
snocross earned 60 total points
ID: 2814064
I haven't tried this but this might work...

Dim pathName As String, fileName As String
pathName$ = "c:\*.*"
fileName$ = Dir$(pathName$, 0)

Do While fileName$ <> ""
   Print fileName$
   fileName$ = Dir$()

If fileName$ = "C:\mcs_data.xls" then

   PUT YOUR CODE HERE TO OPEN THE FILE

End if

Loop
0
 

Author Comment

by:kspuea
ID: 2815566
Thanks a lot, snocross!
It works perfectly to me!
0
 
LVL 5

Expert Comment

by:snocross
ID: 2816920
You're welcome, I'm glad it worked!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now