This question is a follow on from a previous question here.
Based on the answer by @Jeeped, it seems that the best way to resolve the issue is to insert this section of code into a macro:
Origin:=65001
This is in order to force my code to import the files in UTF-8 format.
The issue now arises that I can't work out how or where to insert the code above in my macro. I have the following macro (that I found online - but can't remember where, so can't credit), that imports a large set of files into the workbook, creating spreadsheets for each file.
Sub Extractions()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayStatusBar = False
Dim FilesToOpen
Dim x As Integer
On Error GoTo ErrHandler
FilesToOpen = Application.GetOpenFilename _
(fileFilter:="Microsoft Excel Files (*.*?), *.*?", MultiSelect:=True, Title:="Files to Import")
If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If
x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x), Delimiter:=Chr(124)
Sheets().Move Before:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend
ExitHandler:
Application.ScreenUpdating = False
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
Resume
End Sub
Any suggestions on how to get around this issue?
EDIT 1:
Thanks to @Rory for his suggestions. After more investigation, it looks like Origin:=65001 is not a valid entry in Workbook.Open.
As such, I'm wondering is there any way that I can keep the original formatting from the text files, which is set to UTF-8, while I import to MFGI, using the code above?