Solved

Unzipping

Posted on 2015-01-06
8
151 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
 
LVL 8

Author Comment

by:itjockey
ID: 40535632
Sir.Gowflow,

Downloading and unzipping work perfect.
Thanks
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In case Office 2010 has not been deployed in your environment, this article may be quite useful. In our office, we wanted a way to deploy Microsoft Office Professional Plus 2010 through an automated batch file via logon script. This article is docum…
In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now