Visual Basic
The good old Visual Basic
Interessante articolo su come editare il formato OPENXML di Excel 2007 utilizzando il buon vecchio VBA o, per estensione, il sempre valido Visual basic 6.
http://www.jkp-ads.com/articles/Excel2007FileFormat02.asp
When it was a matter of zipping a file, I always choosed the easy way: find a thirdy part activex or dll which could do the job for me.
This time, I wanted to find my way to zip a file using Visual Basic 6 (or Visual Basic for Application - aka VBA) and the windows shell. The consderation came from the fact that, since Windows XP, the support of zipping-unizzping files is a native feature of the OS.
After a long search and multiple fixes, I finally came up with a stable solution which I'm going to quickly explain and post...
This is a very quick example about OLEDB and read a text (.txt) file using Visual Basic 6.
The text file must be formatted as a simple CSV file with a field separator. Something like this
Test.txt
a;1;Test
b;2;Test
c;3;Test
d;4;Test
Supposing "Test.Txt" is stored in the root of the C: harddrive, the code will look like
----------------------------------------
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = CreateObject("ADODB.Connection")
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=""text;HDR=No;FMT=Delimited'"""
Set rs = CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM Test.txt", cn, 0, 1, 1
While Not rs.EOF
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, rs.Fields(2).Value
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
----------------------------------------
Take a look to the connection string
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\;Extended Properties=""text;HDR=No;FMT=Delimited'"""
the Data Source=c:\; is the key. If you...