Consulting

Results 1 to 4 of 4

Thread: Error 424: what am I missing?

  1. #1
    VBAX Regular
    Joined
    Aug 2006
    Posts
    82
    Location

    Error 424: what am I missing?

    I have the following code that allows me to select a file. Once I have selected it, however, and click Open, I get Run-time Error 424 (Object required).

    ...
    1 Dim csv_file As Excel.Workbook
    2 Dim prq_file As Excel.Workbook
    3
    4 Set prq_file = ActiveWorkbook
    5
    6 Set csv_file = Application.GetOpenFilename("All files, *.csv")
    7 If csv_file = False Then
    8 Exit Sub
    9 End If
    ...

    I then tried changing line 6 to a With block, but then got a 91 error.

    ...
    6 With Application
    7 csv_file = .GetOpenFilename("All files, *.csv")
    8 End With
    ...

    Can someone please tell me what I'm missing? How can I rewrite this to get the file to open upon selection? Thank you.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Works fine for me without the set and with or without With.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2006
    Posts
    82
    Location
    Thanks xld. Is there any reason why your code worked and mine didn't if they are the same? What might cause that discrepancy?

  4. #4
    VBAX Regular
    Joined
    Aug 2006
    Posts
    82
    Location
    I took 'as Excel.Workbook' off of my Dim statements, and now it works fine. Not sure I understand that, but I've got what I need.

Posting Permissions

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