i am trying to pull in the field names from a closed Excel file using ADOX into a Dictionary object. However, some column names are ENCLOSED in Single quotes or some are just PREFIXED or SUFFIXED with a Single-quote.
"'GLOBAL VIT/ACE'" OR "'GLOBAL SAM/DUN" OR "GLOBAL SUN SANDS'"
Now this is a cause of headache as i am unable to open a Recordset later and code is resulting in errors.
right now, when i try to rename the Fieldnames using ADOX, i get
"Database is read-only"
so,
Set cols = CreateObject("Scripting.Dictionary")
i = 0
j = 0
blnSingleQuotes = False
For Each fld In objCat.tables(sSheet(1) & "$").Columns
If InStr(1, "~" & UCase(fld.Name), "~" & UCase("Global")) > 0 Then
cols.Add CStr(i), fld.Name
i = i + 1
ElseIf InStr(1, "~" & UCase(fld.Name), "~'" & UCase("Global")) > 0 Then
If Right(UCase(fld.Name), 1) <> "'" Then
fld.name=replace(fld.name,"'","")
cols.Add CStr(i), fld.Name & "'"
i = i + 1
End If
End If
next fld
My question is how do i remove them from the file using ADOX without opening the file? if not this way, then is there an alternative without opening file?
P.S: I am not opening file because file takes time as it is very huge in size.