Hello
I am writing a macro that changes the filepath for an existing text file import as a QueryTable. I want to set the connection parameters to variables and reapply them with a different filepath.
This works fine for all parameters except TextFilePlatform. I want to set it to the code page (eg. 437 for IBM-PC, 65000 for Unicode)
VBA help says that
XlPlatform can be one of these XlPlatform constants.
xlMacintosh
xlMSDOS
xlWindows
and .QueryTable.TextFilePlatform has a number that refers to one of these constants.
However, the macro recorder assigns a code page number to the TextFilePlatform property.
How do I assign a variable to original code page and not have it reset to the default Windows (ANSI)?
I am writing a macro that changes the filepath for an existing text file import as a QueryTable. I want to set the connection parameters to variables and reapply them with a different filepath.
Code:
Dim DataType() as Variant
Dim Platform as Integer
Dim TableCell As Range
Dim TabDelimiter as Boolean, CommaDelimiter as Boolean
Set TableCell = Wksht.Range("A10")
ReDim DataType(1 To UBound(TableCell.QueryTable.TextFileColumnDataTypes))
DataType = TableCell.QueryTable.TextFileColumnDataTypes
TabDelimiter = TableCell.QueryTable.TextFileTabDelimiter
CommaDelimiter = TableCell.QueryTable.TextFileCommaDelimiter
Platform = TableCell.QueryTable.TextFilePlatform
With Wksht.Range("A10").QueryTable
.Connection = ConnectPath
.TextFileColumnDataTypes = DataType
.TextFilePlatform = Platform
.TextFileParseType = xlDelimited
.TextFileTabDelimiter = TabDelimiter
.TextFileCommaDelimiter = CommaDelimiter
End With
This works fine for all parameters except TextFilePlatform. I want to set it to the code page (eg. 437 for IBM-PC, 65000 for Unicode)
VBA help says that
XlPlatform can be one of these XlPlatform constants.
xlMacintosh
xlMSDOS
xlWindows
and .QueryTable.TextFilePlatform has a number that refers to one of these constants.
However, the macro recorder assigns a code page number to the TextFilePlatform property.
How do I assign a variable to original code page and not have it reset to the default Windows (ANSI)?