Excel VBA: Validate Code Page Identifier Exists

I am creating query tables in VBA. (See a sample from Ejgil below.) Nonetheless, the query table asks for a .textfileplatform. Basically this is one of 152 code page identifiers installed in Windows. Sometimes Windows may or may not have the one you are looking for. Example 1252 below is a 'Western European' Code page identifier, which for whatever reason may/may not be installed on a machine in Canada etc., What VBA would I use to validate a code page identifier exists?

 With Selection.QueryTables(1)
        .Connection = "TEXT;" & CsvFileName
        .TextFilePlatform = 1252
        .TextFileStartRow = 1
        .TextFileParseType = xlDelimited
        .TextFileTextQualifier = xlTextQualifierDoubleQuote
        .TextFileConsecutiveDelimiter = False
        .TextFileTabDelimiter = False
        .TextFileSemicolonDelimiter = False
        .TextFileCommaDelimiter = True
        .TextFileSpaceDelimiter = False
        .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 3, 3)
        .TextFileTrailingMinusNumbers = True
        .Refresh BackgroundQuery:=False
    End With


More on Code Page Identifiers is at this link ---> https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx
ouestqueAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

als315Commented:
Code Pages are stored in C_XXXXX.nls files (in windir\system32 folder). You can check existence of file:
Public Function chk_CP(CP As String) As Boolean
Dim r As String
     r = Environ("windir") & "\system32\C_" & CP & ".nls"
     r = Dir(r)
     chk_CP = False
     If Len(r) > 0 Then chk_CP = True
End Function
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ouestqueAuthor Commented:
Really Cool als315. Just some clarification. If someone is running Windows 64 bit instead of 32 bit, would the path be different. (i.e., "/system64" instead of "system32" etc.,) If so what would the new path be?
0
als315Commented:
They are always in system32
0
ouestqueAuthor Commented:
Thanks als315!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.