0

Im trying to open a csv file in my vba code but after opening the file it comes up with an error "Cant execute in break mode"

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

The error arises once the file is opened with the Workbooks.Open command

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
Chudlee
  • 15
  • 4
  • your code runs well, but I have not your csv – patel May 12 '19 at 07:16
  • Ok Ive continued to try and find an answer, The error only occurs when stepping through the code in VBE using F8, hit F5 and no error, I don't understand so anyone with info I would like to hear from. – Chudlee May 12 '19 at 08:07
  • Possible duplicate of [excel 2010 VBA throws "can't execute code in break mode" while stepping](https://stackoverflow.com/questions/19624411/excel-2010-vba-throws-cant-execute-code-in-break-mode-while-stepping) – PaulvdElst May 12 '19 at 10:41
  • If you're having this problem seemingly without reason - this has solved it for me in the past: https://www.businessprogrammer.com/code-execution-has-been-interrupted/ – Tim Williams May 12 '19 at 21:07

1 Answers1

0

@PaulvdElst your response seems the closest description to the problem. Im accepting that using F5 in VBE as the solution

Chudlee
  • 15
  • 4