+ Reply to Thread
Results 1 to 4 of 4

Help:Run-time error '1004'

  1. #1
    Ken Hudson
    Guest

    Help:Run-time error '1004'

    I'm running Windows 2000 and Excel 2003.
    When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
    object 'Workbooks' failed" error.
    Can someone tell me why?
    TIA

    Sub Macro()
    Workbooks.Open Filename:= _
    "C:\downloads\GPF_PY.xls"
    End Sub



    --
    Ken Hudson

  2. #2
    Dave Peterson
    Guest

    re: Help:Run-time error '1004'

    I'd guess that the file didn't exist.

    Typing error in the folder/filename????

    Ken Hudson wrote:
    >
    > I'm running Windows 2000 and Excel 2003.
    > When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
    > object 'Workbooks' failed" error.
    > Can someone tell me why?
    > TIA
    >
    > Sub Macro()
    > Workbooks.Open Filename:= _
    > "C:\downloads\GPF_PY.xls"
    > End Sub
    >
    > --
    > Ken Hudson


    --

    Dave Peterson

  3. #3
    Ken Hudson
    Guest

    re: Help:Run-time error '1004'

    Thanks for the reply. This was really puzzling to me.
    The initial file was saved as a CSV file and then opened in Excel and saved
    as an Excel file. It did exist as an Excel file.
    The problem was that, when it was saved as a CSV file, its worksheet brought
    the default name ".csv)GENSOFMO(2)" with it. I saved the file in Excel with
    that worksheet name. I can open the workbook "manually", but got the error
    when trying to use VB.
    I renamed the worksheet and life is good again.
    --
    Ken Hudson


    "Dave Peterson" wrote:

    > I'd guess that the file didn't exist.
    >
    > Typing error in the folder/filename????
    >
    > Ken Hudson wrote:
    > >
    > > I'm running Windows 2000 and Excel 2003.
    > > When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
    > > object 'Workbooks' failed" error.
    > > Can someone tell me why?
    > > TIA
    > >
    > > Sub Macro()
    > > Workbooks.Open Filename:= _
    > > "C:\downloads\GPF_PY.xls"
    > > End Sub
    > >
    > > --
    > > Ken Hudson

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    Danny Boy via OfficeKB.com
    Guest

    re: Help:Run-time error '1004'

    Hi Ken

    This script will allow you to select the file you wish to open, if the format
    you want ins't csv then change it to desired format

    Application.DisplayAlerts = False
    Application.ScreenUpdating = False

    fileToOpen = Application _
    .GetOpenFilename("Comma Delimited (*.csv), *.csv")
    If fileToOpen <> False Then
    TextBox2.Value = "Opening " & fileToOpen
    Else
    Exit Sub
    End If

    Workbooks.OpenText Filename:="" & fileToOpen
    DoEvents

    --
    Message posted via http://www.officekb.com

+ 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