macro separates .csv by comma, despite separator set to semicolon

后端 未结 2 1523
太阳男子
太阳男子 2021-01-28 05:18

Within the code attached below, macro opens .csv with values separated by semicolon and comma (at least it looks like it\'s doing so), despite comma speparator set to false and

2条回答
  •  情歌与酒
    2021-01-28 06:05

    There are issues with your code as commented by @Tim Williams and @Nick.McDermaid. It is not clear what you want to achieve. However regarding opening Semicolon Delimited text file you may rename the file to .txt and open like

    xlFileName = chooseFiles.SelectedItems(k)
            TmpFlName = Path & "TmpCsv.txt"
            If Dir(TmpFlName) <> "" Then Kill TmpFlName
            FileCopy xlFileName, TmpFlName
            Workbooks.OpenText Filename:=TmpFlName, Origin:= _
            1250, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
            ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False _
            , Space:=False, Other:=False, TrailingMinusNumbers:=True, Local:=False
    

    issue was delimiter option will only work when .txt file is used not .csv.

提交回复
热议问题