+ Reply to Thread
Results 1 to 10 of 10

Runtime error 1004,

  1. #1
    Registered User
    Join Date
    02-22-2007
    Posts
    7

    Runtime error 1004,

    HeY all,
    Heres the deal, getting a error message when opening a workbook "Runtime error 1004" I dont know much about excel and the user explained it to me as best she could . Here is where the script bugs:

    Sub auto_open()
    fdist = ActiveWorkbook.Name
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Worksheets("f_cumul").Cells.ClearContents
    Worksheets("f_cumul").Cells.ClearFormats
    Worksheets("vtes_dj").Select
    Range("a1").Select
    Selection.End(xlDown).Select
    lf = ActiveCell.Row
    Range(Cells(2, 1), Cells(lf, 7)).ClearContents
    Range(Cells(2, 1), Cells(2, 7)).Value = "x"
    Workbooks.Open Filename:="\\LIVE\VOL11\DB_DIST\FOURNIER\CO2_INFO.XLS", ReadOnly _
    :=True
    Range("A2").Select
    ActiveWindow.Visible = False
    Workbooks.Open Filename:="\\LIVE\VOL6\Dept\FOURNIER\F_CUMUL.XLS", _
    ReadOnly:=True
    Sheets("sheet1").Select
    Columns("a:g").Copy
    Windows(fdist).Activate
    Worksheets("f_cumul").Cells(1, 1).PasteSpecial Paste:=xlValues
    Workbooks("f_cumul.xls").Close
    Windows(fdist).Activate
    Worksheets("f_cumul").Columns("D:D").NumberFormat = "d-mmm-yy"
    Worksheets("reserve").Select
    Columns("e:g").ClearContents
    Selection.QueryTable.Refresh BackgroundQuery:=False
    Workbooks.Open Filename:="\\live\VOL11\DB_DIST\FOURNIER\RAP_FOU.XLS", _
    UpdateLinks:=0, ReadOnly:=True
    Sheets("rap_fait").Select
    Columns("A:K").Select
    Selection.Copy
    Windows(fdist).Activate
    Sheets("rap_encours").Select
    Range("a1").Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    Columns("I:I").Select
    Application.CutCopyMode = False
    Selection.NumberFormat = "dd-mmm-yy"
    Windows("rap_fou.xls").Close
    Windows("fou_dist.xls").Activate

    Sheets("dist").Select
    Range("s5").Select
    'Workbooks(fdist).Save

    End Sub


    Thanks for any help

    EDIT: bolded text is where the macro fails.
    Thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Pepito_1ton,

    I don't see where you tell VBA to connect to your SQL server. The Select.Query statement won't work without an established connection to the Database.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    02-22-2007
    Posts
    7
    I forgot to say that this file works on another computer with very similar configuration. I've dupliacted the odbc sources from the machine that works to the one that doesnt and it didnt help. Does this give you any ideas?

  4. #4
    Registered User
    Join Date
    02-22-2007
    Posts
    7
    No ideas of why it works on another machine??
    By loking at this script, are there any odbc driver sthat should be in place for it to work , that would at least tell me where to look next.
    Thanks again

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Pepito_1ton,

    It looks like it might be a library reference isn't set in VBA. What database are you migrating the data from? This will help me answer which reference you'll need to check for and add if needed.

    Sincerely,
    Leith Ross

  6. #6
    Registered User
    Join Date
    02-22-2007
    Posts
    7
    Hello Leith Thank you for your reply,
    It is a access database. We ahve been getting this problem since Microsoft Office was reinstalled on this computer but in a diffrent language...I tried it on a diffrent computer with office of the same language as on the pc that works and i get "Runtime error 1004, \\LIVE\VOL11\CO2_INFO.XLS could not be found. Check the spelling of the file name and verfiy that the file location is correct.

    ??The file location is 100% correct and I opened the file myself and it opens fine.
    The file CO2_info.xls is also in the macro posted above..hope this information can help you.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Pepito,

    Open Excel on the computer your macro runs on. Open the VBE by pressing ALT+F11. Select Tools > References (Alt+T then R). Make a list of all the marked checkboxes listed. Then open Excel on the other computer and check the references it has checked. Check any that aren't on your original list.

    Sincerely,
    Leith Ross

  8. #8
    Registered User
    Join Date
    02-22-2007
    Posts
    7
    I compared the two and they both have the same references checked.

    Regards

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Pepito,

    This looks to be a shared network file. If so, the user may not have the proper network settings and/or access rights to retrieve a shared network file. You may want to have someone in your IT dept look at, or talk to the system administrator about the proper settings.

    Sincerely,
    Leith Ross

  10. #10
    Registered User
    Join Date
    02-22-2007
    Posts
    7
    Ive eleminated that possibility because I am using the administrator account which has access to all the files on the network.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1