I am using a macro to open a set of selected .csv files, apply the TextToColumns command and then save them as a .xlsx file for further manual processing. One particular .csv file has around 2000 lines in it if I open it manually; when the file is opened via the macro it only contains a total of 1064 lines. Does anyone know what causes this or how I can fix it? Relevant code:
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-file 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
For some reason, setting the Local parameter to True fixed it, I still don't know how or why so if anyone has any insights I'd appreciate it. Fixed code:
Workbooks.Open vrtSelectedItem, Local:=True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.