打开CSV文件会在VBA代码中导致中断模式

时间:2019-05-12 04:21:35

标签: excel vba

我正在尝试用我的vba代码打开一个csv文件,但是打开文件后出现错误“无法在中断模式下执行”

Sub extern_rd_grab()
Dim file_name2
Dim wb As Workbook
Dim sheet_name As String
Dim sCSVFullName As String
Dim sWbkFullName, sFileRoot As String
Application.ScreenUpdating = False
Sheets("Round Scores").Select

For x = 1 To 23:
    file_name1 = "2015-R" & x & "_TSstat.csv"
    sFileRoot = Left$(file_name1, InStrRev(file_name1, ".") - 1)
    sWbkFullName = sFileRoot & ".xlsx"
    file_name2 = "C:\Users\Sean\Desktop\2015 Stats\" & file_name1
    Workbooks.Open Filename:=file_name2
    Set wb = ActiveWorkbook
    wb.SaveAs sWbkFullName, xlWorkbookDefault
Next

使用Workbooks.Open命令打开文件后,就会出现错误

1 个答案:

答案 0 :(得分:0)

@PaulvdElst您的回答似乎是最接近问题的描述。我接受在VBE中使用F5作为解决方案