Solved

Unzipping

Posted on 2015-01-06
8
168 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 30

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 30

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

To Patch or not to Patch? That is the question!

Don't get caught out like thousands of others around the world in the recent Ransomware Fiasco!
Discuss..
- Why it's not a good idea to wait before Patching
- Sensible approaches to Patching discussed
- Add your feedback, comments and suggestions

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa‚Ķ

734 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