Solved

Unzipping

Posted on 2015-01-06
8
163 Views
Last Modified: 2015-01-07
Hi Experts,

I have one WB with VBA code in it, which downloads files from WEB. I am looking the code for  6th button "BSE Equity".
this button download file and save to "D:\AmiBroker Data\BSE\Eq" as zip, I need to add some steps which unzip those files via Code.

See attached

Thanks
Incoporated-Download-File-V02.xlsm
0
Comment
Question by:itjockey
  • 5
  • 2
8 Comments
 
LVL 2

Assisted Solution

by:Pratik Makwana
Pratik Makwana earned 25 total points
ID: 40534981
Use below code...
Sub ProcessFile()
    Dim SourcePath As String, Filename As String

    SourcePath = "D:\AmiBroker Data\BSE\Eq\"

    Filename = Dir(SourcePath)

    Do While Len(Filename) > 0
        If Right(Filename, 3) = "zip" Then
        Call UnZipFile(SourcePath, Filename)
        Kill SourcePath & Filename
        End If
        Filename = Dir()
    Loop
End Sub

Sub UnZipFile(strTargetPath As String, Fname As String)
    Dim oApp As Object
    Dim FileNameFolder As Variant

    If Right(strTargetPath, 1) <> Application.PathSeparator Then
        strTargetPath = strTargetPath & Application.PathSeparator
    End If

    FileNameFolder = strTargetPath
    dPath = "D:\AmiBroker Data\BSE\Eq\"
    Set oApp = CreateObject("Shell.Application")
    On Error Resume Next
    oApp.Namespace(dPath).CopyHere oApp.Namespace(FileNameFolder & Fname).Items
    On Error GoTo 0
End Sub

Open in new window

0
 
LVL 29

Accepted Solution

by:
gowflow earned 475 total points
ID: 40535168
ok here it is in the attached file it has the following updated from last version:

1) Included access to unzip all files shown in the said directory on the BSE Equity activation.

2) Included a WARNING messagebox just prior deleting files. I believe this is mandatory just letting you know what directory it will delete files from (In case for some reason the variable have not been initialized correctly you are at least warned before deleting files in this directory) As you know there is a routine that delete all files in the said directory just prior to activation of the routine. and in the past for wrong initialization it had deleted files from a wrong location which is something we do not want to happen. I know you don't like message boxes but this one is a MUST !

3) Included now a TRACE (if trace is selected) to show that files are being unzipped and this routine is being accessed.

Pls check the version and let me know.
gowflow
Incoporated-Download-File-V03.xlsm
0
 
LVL 8

Author Comment

by:itjockey
ID: 40535603
Pratik Bhai,

Not so familiar with VBA Coding may be your code is work fine, but I don't know how to implement.

Thanks
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Author Comment

by:itjockey
ID: 40535632
Sir.Gowflow,

Downloading and unzipping work perfect.
Thanks
0
 
LVL 8

Author Closing Comment

by:itjockey
ID: 40535637
Thanks & Perfect.
0
 
LVL 8

Author Comment

by:itjockey
ID: 40535640
May I ask follow up?
0
 
LVL 29

Expert Comment

by:gowflow
ID: 40535730
yes for sure
gowflow
0
 
LVL 8

Author Comment

by:itjockey
ID: 40535778
Here It Is.

Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question