Re: How to automate the data impor process from Excel to Acc
HI, LT,
#1. I am sure it is Excel and have run successfully if I use "C:|Document and Settings\myname\My Documents\testexcelfile.xls".
#2. Put ActiveWorkbook.Path & "\"& ActiveWorkbook.Name in MsgBox and it showed correct path "C:|Document and Settings\myname\My Documents\testexcelfile.xls" on the MsgBox.
#3. When put ActiveWorkbook.Path code into the original code to replace C:\.... The error message showed up like this:
"Run-time Error '2495' - Application-defined or object-defined error"
#4. Check help on this error and the following content is related to this error.
[It may be that in accessing objects from other applications, an error was propagated back to your program that can't be mapped to a Visual Basic error.
Check the documentation for any objects you have accessed. The Err object's Source property should contain the programmatic ID of the application or object that generated the error. To understand the context of an error returned by an object, you may want to use the On Error Resume Next construct in code that accesses objects, rather than the On Error GoTo line syntax.
Note In the past, programmers often used a loop to print out a list of all trappable error message strings. Typically this was done with code such as the following:
For index = 1 to 500
Debug.Print Error$(index)
Next index
Such code still lists all the Visual Basic for Applications error messages, but displays "Application-defined or object-defined error" for host-defined errors, for example those in Visual Basic that relate to forms, controls, and so on. Many of these are trappable run-time errors. You can use the Help Search dialog box to find the list of trappable errors specific to your host application. Click Search, type Trappable in the first text box, and then click Show Topics. Select Trappable Errors in the lower list box and click Go To. ]
#5. I am not quite sure what it meant for the last paragraph. Can you give some insight?
Thanks,