Vba changes to be made

  • Below VBA CODE working properly to extract data from zip file if my zip file presents in C:\Users\max\Downloads..
    i.e if i import data , it unzip the zipped file and copy the csv data inside zip file and paste it in the workbook which i need, but the problem is "fo26DEC2016bhav.csv.zip" zip name will change daily ,and i need to download the data and update it , in my workbook worksheet, so my vba code has to be changed as per it can daily update data irrespective of zip name and worksheet name in my workbook, so kindly help me to correct






    below is zip file and have upload my excel file


    https://www.nseindia.com/conte…C/fo26DEC2016bhav.csv.zip



    my excel file


    I have asked same question in this forum too.
    http://www.vbaexpress.com/foru…elp-me-to-correct-the-vba

  • Re: Vba changes to be made


    Could you use the GetOpenFilename method to assign the zip file name to a variable?


    Code
    Dim strZipFileToOpen As String
        strZipFileToOpen = Application.GetOpenFilename("zip Files (*.zip), *.zip")
        strZipFile = strDestinationFolder & "\" & strZipFileToOpen

    If I've been helpful, let me know. If I haven't, let me know that too. 

  • Re: Vba changes to be made


    Something like this maybe?


    Code
    strFileName = Application.GetOpenFilename("zip Files(*.zip),*.zip")
        'strFileName = "fo26DEC2016bhav.csv"
        
        str7ZIP = "C:\Program Files (x86)\7-Zip\7z.exe"
        strDestinationFolder = ActiveWorkbook.Path
        
        strZipFile = strDestinationFolder & "\" & strFileName
        'strZipFile = strDestinationFolder & "\fo26DEC2016bhav.csv.zip"


    Just changed the 'strFileName' and 'strZipFile' lines

  • Re: Vba changes to be made


    The GetOpenFileName method is explained here: http:////msdn.microsoft.com/en-us/library/office/ff834966.aspx



    It works in your code just as you would open a file, except that it just gets the name of the file you wish to open, but does not open it.


    My earlier reply was just a suggestion as to how it could be implemented in your existing subroutine.

    If I've been helpful, let me know. If I haven't, let me know that too. 

  • Re: Vba changes to be made


    Yes but he could set his zip name that way. If it is always changing. Just for a method not to have retyping his code all the time.
    Right?

  • Re: Vba changes to be made


    From the level of expertise needed to write your code as it is now, I assumed you would be able to incorporate the needed changes. With that said, try this untested modification...


    If I've been helpful, let me know. If I haven't, let me know that too. 

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!