Solved

How to avoid this error message?

Posted on 2000-05-12
8
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lotus Domino Server Failure 1 206
Lotus notes email code 13 103
Lotus Domino server 9 7 91
Access VBA to send PDF attachment from C Drive using Lotus Notes. 30 154
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

751 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