Results 1 to 11 of 11

Thread: Solved: OpenText Method and Find Replace Syntax

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    Try importing with this code (fixing the path of course). If you look at the image below, you will see you can set the import options for individual columns. That should get you round the date conversion issue.

    [vba]
    Sub Macro1()
    Dim MyPath As String
    MyPath = "C:\AA\C_H__.txt" '<=== Change to suit
    With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & MyPath, _
    Destination:=Range("A1"))
    .Name = "C_H__"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 437
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = False
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileOtherDelimiter = ":"
    .TextFileColumnDataTypes = Array(1, 1, 2, 2, 1, 1, 1, 1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
    End With
    Call Cleans
    End Sub
    Sub Cleans()
    Dim Cel As Range
    For Each Cel In ActiveSheet.UsedRange
    Cel.Value = Trim(Cel.Value)
    Next
    End Sub
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    744
    Location

    Solved: Thank you!

    It worked perfectly. Thank you very much.

    Sorry for being naive but how do you mark it as "Solved"?.
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

Posting Permissions

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