PDA

View Full Version : Run-time error '1004' in import macro


geeorbit
09-19-03, 04:22
I have written a macro to import data from a text file into a new excel file, copy that data to the database and finally delete the new file opened for importing purpose.
However the command .Refresh BackgroundQuery:=False
gives:
Run-time error '1004'
Application-defined or object-defined error.

At times it executes without any error.
Any clue regarding how I can solve this ?

Thanks in advance

yannfoubert
11-26-03, 06:08
Originally posted by geeorbit
I have written a macro to import data from a text file into a new excel file, copy that data to the database and finally delete the new file opened for importing purpose.
However the command .Refresh BackgroundQuery:=False
gives:
Run-time error '1004'
Application-defined or object-defined error.

At times it executes without any error.
Any clue regarding how I can solve this ?

Thanks in advance

Hi!

Did you have the solution for your problem? I have the same one and can't find out what's going wrong.

Thanks in advance.

Yann

shades
11-26-03, 16:27
I suspect that because you deleted the original text file, Refresh is looking for it but can't find it - hence "Application-defined or object-defined error".

kenji4861
02-17-04, 02:33
I'm having the same problem.

This problem does occur if the file does not exist, but it also happens on bigger files. Also seems to occur less on the PC, but occurs more on the Mac.. (I'm using this on Excel).

yannfoubert
02-17-04, 06:51
Originally posted by kenji4861
I'm having the same problem.

This problem does occur if the file does not exist, but it also happens on bigger files. Also seems to occur less on the PC, but occurs more on the Mac.. (I'm using this on Excel).

I finally found the problem I had. My macro made a request to a database, then I wanted to report the result in Excel. The problem was that some data began by char like '-', '+' or '=' which are interpreted as functions in Excel. I just corrected it by adding a ''' at the begining of each string having these char at first.

In fact, this error can have many reasons. It's not a very accurate message... Something like a dummy error. One more time thanks Bill!