Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2003
    Location
    Hyderabad
    Posts
    5

    Unanswered: Run-time error '1004' in import macro

    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

  2. #2
    Join Date
    Nov 2003
    Posts
    2

    Question Re: Run-time error '1004' in import macro

    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

  3. #3
    Join Date
    Oct 2003
    Posts
    1,091
    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".
    old, slow, and confused
    but at least I'm inconsistent!

    Rich
    (retired Excel 2003 user, 3/28/2008)

    How to ask a question on forums

  4. #4
    Join Date
    Feb 2004
    Posts
    2
    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).

  5. #5
    Join Date
    Nov 2003
    Posts
    2
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •