• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Search for file name

sms2luv

Member
Hi,
We have a intranet site to download data, when I open the downloaded file it opens as an excel file.
The first I download and run the file it opens as a name like AHT, when I download 2nd time it gets downloaded and name changes to AHT(2), 3rd time its AHT(3) and so on.
I copy the entire data from that file.
I have made a macro to paste the data which I copied earlier.

Is there any way, I can make a macro to automatically copy and paste data from the file which is already open like AHT or AHT(2) the problem here is that the file names increments everytime its downloaded.

In have used a code like
Worksheet(AHT).Range("A1"). Pastespecial
 
If you have copied the data you needed, why not delete the AHT file ? That way when it is downloaded again, the name will remain the same.

If you don't want to delete the file, move it to another folder after copying the data.
 
Thanks for the reply.
I am not saving the file, when I download the file, I get a prompt to open, save of cancel.
I click on open and do not save the file.
Its the way the tool is designed as the name Increments every time the file is opened.
I extract the date 4 times a day so I guess the file name would be Aht, Aht(1), Aht(2), Aht(3).
Is there any way I can tell the macro to look for these files and copy data.
 
I am presuming (maybe falsely) these files all have the same extension? i.e., Aht.xls, Aht(1).xls, Aht(2).xls etc.

Change your approach ... download each file to a dedicated directory. Call it: "My Aht File Download Repository Folder" or something catchy.

Code your macro to open the file from there, having the macro search for anything with the .xls extension. Since there will always and only be an .xls file in that folder, the macro can only open that one file.

Copy the data, then "delete" the file.

Unless there is something I've missed, the only change you'll be making to your code is the approach you've taken up til now. Don't just open the file ... download it first, open it, then delete it.
 
I have made a macro to paste the data which I copied earlier.

Post the macro you already use to paste the copied data (preferably post your entire workbook).

Post an example file that is downloaded (Aht).

Specify what data is copied - is that data always in the same location for all files downloaded ? In other words: always in the same cell / s ?

That would be a start.
 
Back
Top