我正在使用宏来打开一组选定的.csv文件,应用TextToColumns命令,然后将它们另存为.xlsx文件以进行进一步的手动处理。如果我手动打开它,一个特定的.csv文件中有大约2000行;当通过宏打开文件时,它只包含1064行。有谁知道是什么导致这个或如何解决它?相关代码:
Dim iFileSelect As FileDialog
Dim vrtSelectedItem As Variant
Set iFileSelect = Application.FileDialog(msoFileDialogFilePicker)
If iFileSelect.Show = -1 Then
Application.DisplayAlerts = False
For Each vrtSelectedItem In iFileSelect.SelectedItems
Workbooks.Open vrtSelectedItem 'After this step the opened _
.csv only contains 1064 out of 2000 lines
'Here a macro is run to convert text to columns
ActiveWorkbook.Close
SetAttr vrtSelectedItem, vbNormal
Kill vrtSelectedItem
Next vrtSelectedItem
Application.DisplayAlerts = True
End If
Set iFileSelect = Nothing
答案 0 :(得分:0)
出于某种原因,将Local参数设置为True修复它,我仍然不知道如何或为什么如此,如果有任何人有任何见解,我会很感激。 固定代码:
Workbooks.Open vrtSelectedItem, Local:=True