Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts

    Why? Object Required error

    Related to my other post, I'm working through this.

    Why am I getting an "object required" error when starting this code? The macro prompts for the file, I select it, then get the error.

    Code:
    Sub DoTheImport()
        Dim FileName As Variant
        Dim Sep As String
    
        FileName = Application.GetOpenFilename(FileFilter:="Text File (*.txt),*.txt")
        If FileName = False Then
            ''''''''''''''''''''''''''
            ' user cancelled, get out
            ''''''''''''''''''''''''''
            Exit Sub
        End If
        Sep = ","
     '  Sep = Application.InputBox("Enter a separator character.", Type:=2)
        If Sep = vbNullString Then
            ''''''''''''''''''''''''''
            ' user cancelled, get out
            ''''''''''''''''''''''''''
            Exit Sub
        End If
        Debug.Print "FileName: " & FileName, "Separator: " & Sep
        ImportTextFile FName:=CStr(FileName), Sep:=CStr(Sep)
    End Sub ' END DoTheImport
    AH, I think I figured it out!!
    Last edited by kweaver; 2016-09-13 at 14:20.

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,823
    Thanks
    135
    Thanked 482 Times in 459 Posts
    Hi

    ..well don't leave our readers in suspenders - what was it?????

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,470
    Thanks
    30
    Thanked 62 Times in 58 Posts
    The FileName was not properly defined.

Posting Permissions

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