0
votes

On Windows, for example I have a file named "report_v1.csv". In the "schema.ini", there is definition for file "report.csv". I don't want to make a copy from "report_v1.csv" and rename it as "report.csv" because it may cost some space. So I try to make a shortcut and rename it to "report.csv".

enter image description here

But when I use ADODB to read data through the shortcut, it prompts error.

Dim conn As New ADODB.Connection
Dim path as String
path = "<some path>"   
    conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=""text;HDR=YES;FMT=Delimited;CharacterSet=65001"";"

enter image description here

So is it possible to read data from a file through its shortcut?

I don't think that's possible. You need to find the way to extract shortcut target (for example like this answers.microsoft.com/en-us/msoffice/forum/all/…) and then use that target for ADODBsarh
Hi @sarh, thanks for your answer. The file name for SQL FROM statement must be compliant with schema.ini definition, to my experience, I am afraid use "SELECT * FROM <target file>" won't work, because the <target file> has a different name.boeingdream