I am trying to create a macro that when run in one workbook will open up another workbook in the background, change column F of this newly opened workbook from text to date, save changes and then close the workbook that was just opened. In the code I am trying I keep getting the error message 'Run-time error '1004': TextToColumns method of Range class failed'. Do you know what is wrong and how I can fix it?
Sub Test()
Dim xlApp As New Excel.Application
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
xlApp.Visible = False
Set xlWB = xlApp.Workbooks.Open("directory_file_to_open")
Set xlWS = xlWB.Worksheets("worksheet_of_data")
xlWS.Unprotect
xlWS.Columns("F:F").TextToColumns Destination:=Range("F1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True
Set xlWS = Nothing
xlApp.DisplayAlerts = False
xlWB.Close True
Set xlWB = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub