<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Visual Basic</title>
        <link>http://blogs.ugidotnet.org/fgiossi/category/Visual Basic.aspx</link>
        <description>The good old Visual Basic</description>
        <language>it-IT</language>
        <copyright>Francesco Giossi</copyright>
        <generator>Subtext Version 2.6.0.0</generator>
        <item>
            <title>Editare file di Excel 2007 da VBA o VB6</title>
            <link>http://blogs.ugidotnet.org/fgiossi/archive/2009/05/08/editare-file-di-excel-2007-da-vba-o-vb6.aspx</link>
            <description>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
&lt;img src="http://blogs.ugidotnet.org/fgiossi/aggbug/96133.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Francesco Giossi</dc:creator>
            <guid>http://blogs.ugidotnet.org/fgiossi/archive/2009/05/08/editare-file-di-excel-2007-da-vba-o-vb6.aspx</guid>
            <pubDate>Fri, 08 May 2009 10:44:11 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/fgiossi/archive/2009/05/08/editare-file-di-excel-2007-da-vba-o-vb6.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/fgiossi/comments/commentRss/96133.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/fgiossi/services/trackbacks/96133.aspx</trackback:ping>
        </item>
        <item>
            <title>How to zip a file using Visual Basic 6 and the Windows Shell</title>
            <link>http://blogs.ugidotnet.org/fgiossi/archive/2009/03/27/how-to-zip-a-file-using-visual-basic-6-and.aspx</link>
            <description>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 right here. The source code is a mix of pieces of code collected here and there. the only att
Attached to the post it's a zip file containing a working example. It zips the files contained in the testFolder directory.
Click here to download the zip.
I'm going to post just the clsZip class I used to support my zipping project.
clsZip.cls
Option Explicit

Private objShell As Object
Private mvarZipFileName As String

Const FOF_NOCONFIRMATION = &amp;amp;H14

Private Sub Class_Initialize()
Set objShell = CreateObject("Shell.Application")
End Sub

Private Sub Class_Terminate()
Set objShell = Nothing
End Sub

Public Property Let ZipFileName(ByVal vData As String)
    mvarZipFileName = vData
End Property

Public Property Get ZipFileName() As String
    ZipFileName = mvarZipFileName
End Property


Private Sub CreateEmptyZip(sPath)

    Dim strZIPHeader As String
    
    Dim fso As Object
    
    strZIPHeader = Chr$(80) &amp;amp; Chr$(75) &amp;amp; Chr$(5) &amp;amp; Chr$(6) &amp;amp; String(18, vbNullChar)
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    With fso
        .CreateTextFile(sPath).Write strZIPHeader
    End With
    
    Set fso = Nothing
    
End Sub

Public Function AddFilesToZip(sFileNames() As String) As Boolean

Dim i As Long
Dim iCount As Long

    On Error GoTo AddFilesToZip_Error
    
    CreateEmptyZip mvarZipFileName
    
    On Error Resume Next
    For i = LBound(sFileNames) To UBound(sFileNames)
        objShell.Namespace("" &amp;amp; mvarZipFileName).CopyHere "" &amp;amp; sFileNames(i), FOF_NOCONFIRMATION
        
        iCount = objShell.Namespace("" &amp;amp; mvarZipFileName).items.Count
    
        Do Until iCount = i + 1
            Sleep 100
            iCount = objShell.Namespace("" &amp;amp; mvarZipFileName).items.Count
        Loop
        
    Next
        
    On Error GoTo 0
    Exit Function

AddFilesToZip_Error:

    MsgBox "Error " &amp;amp; Err.Number &amp;amp; " (" &amp;amp; Err.Description &amp;amp; ") in procedure AddFilesToZip of Modulo di classe clsZip"

End Function
Public Function UnzipToFolder(sFolderName As String) As Boolean

    objShell.Namespace("" &amp;amp; sFolderName).CopyHere objShell.Namespace("" &amp;amp; mvarZipFileName).items

End Function



Technorati tags: zip, Visual basic 6, vba, windows shell
&lt;img src="http://blogs.ugidotnet.org/fgiossi/aggbug/95809.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Francesco Giossi</dc:creator>
            <guid>http://blogs.ugidotnet.org/fgiossi/archive/2009/03/27/how-to-zip-a-file-using-visual-basic-6-and.aspx</guid>
            <pubDate>Fri, 27 Mar 2009 12:40:32 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/fgiossi/archive/2009/03/27/how-to-zip-a-file-using-visual-basic-6-and.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/fgiossi/comments/commentRss/95809.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/fgiossi/services/trackbacks/95809.aspx</trackback:ping>
        </item>
        <item>
            <title>OLEDB and text files</title>
            <link>http://blogs.ugidotnet.org/fgiossi/archive/2007/10/07/oledb-and-text-files.aspx</link>
            <description>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 plan to store your text file in a different folde, let's say "c:\documents and settings\Auser\Documents\myTestFiles\", you are required to change the connection string this way:
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\documents and settings\Auser\Documents\myTestFiles\;Extended Properties=""text;HDR=No;FMT=Delimited'"""
&lt;img src="http://blogs.ugidotnet.org/fgiossi/aggbug/88799.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Francesco Giossi</dc:creator>
            <guid>http://blogs.ugidotnet.org/fgiossi/archive/2007/10/07/oledb-and-text-files.aspx</guid>
            <pubDate>Sun, 07 Oct 2007 21:00:14 GMT</pubDate>
            <comments>http://blogs.ugidotnet.org/fgiossi/archive/2007/10/07/oledb-and-text-files.aspx#feedback</comments>
            <wfw:commentRss>http://blogs.ugidotnet.org/fgiossi/comments/commentRss/88799.aspx</wfw:commentRss>
            <trackback:ping>http://blogs.ugidotnet.org/fgiossi/services/trackbacks/88799.aspx</trackback:ping>
        </item>
    </channel>
</rss>