Solved

Unzipping

Posted on 2015-01-06
8
170 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:Naresh Patel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 31

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:Naresh Patel
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
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 
LVL 8

Author Comment

by:Naresh Patel
ID: 40535632
Sir.Gowflow,

Downloading and unzipping work perfect.
Thanks
0
 
LVL 8

Author Closing Comment

by:Naresh Patel
ID: 40535637
Thanks & Perfect.
0
 
LVL 8

Author Comment

by:Naresh Patel
ID: 40535640
May I ask follow up?
0
 
LVL 31

Expert Comment

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

Author Comment

by:Naresh Patel
ID: 40535778
Here It Is.

Thanks
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

My attempt to use PowerShell and other great resources found online to simplify the deployment of Office 365 ProPlus client components to any workstation that needs it, regardless of existing Office components that may be needing attention.
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
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…

636 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