Consulting

Results 1 to 4 of 4

Thread: Open .csv from code

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Open .csv from code

    How can I change this to not be fixed width:

    [VBA]Workbooks.OpenText filename:=UsGrowersTextFile, _
    Origin:=437, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array( _
    Array(0, 1), Array(49, 1)), TrailingMinusNumbers:=True[/VBA]

    I want it to be comma separated. However, it does not autocomplete for me to find the DataType for .csv
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    This works for me
    [VBA]
    Workbooks.Open Filename:="S:\telnos\outlook.csv"
    [/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'

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    mdmackillop,

    that is not the issue (my fault) it opens but I want it to separate into different columns by commas not by Fixed Width - automatically. There are about 10 columns in the text file that need to separate by commas.
    Thank You,
    Daniel Blois
    http://studenthacker.blogspot.com/

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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'

Posting Permissions

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