Get data file without through PC download dialog/popup  window from Internet

Posted on 2010-11-20
Last Modified: 2012-05-10
Dear EE ExpertS,

I get one website for download my data files and when I input edit my product No and press enter key ,the IE7
window will  display data I want according to  my input product No. , and so I try to do testing ,  I try to
disconnect internet  and then after that I try to click its download button in the webpage,the  download popup
window  is  still  comming out or appear  and I still  be able to save the exact file I want after click save button .

So I wonder why I can save the  file even I  disconnect internet ,So I believe it is because when I input edit
the product NO and press enter key , the data file is fetched already into Cache file or memory  in my  PC before
I disconnect internet. So my question is if so, whether I am able to save my file without going through  the
download  or popup memu process  that will help me to save a lot VBA download file  program code and
exceute time with automation

I go to seach to my PC directory, finally I found one directory which is asynchronous to what I nagivate in IE7 before.
In such directory it has so many  sitename and image, files name that   I fire IE website before in recent days

The directory name is like C:\users\myaccount\Appdata\Local\Microsoft\Windows\Temporary Internet Files\Coneten.IE5\P5LBXH2C\
something like that  in Window Vista , it seems it is mirror or Cache file to my PC memory, Is it true ?

In other words, I am able to save files directly from the Temporary Internet Files directory,Is it Right ?
So if so, I am easier to use VBA and following code to check file is existed or not and copy it to my directory from
the Temp Internet File directory, Is it right ? Please advise
Since I have a lot of files want to download in target website, so I prefer to do it in VBA with everything in auto
that will  save a lot of execute time when number of file to be download is huge like 1000 files

I try it before, but it is  fail and it might be not as much as easy I say.. Or  I ask where the Cache file is stored for internet file
in most in our PC 's memory and Cache file directory ?  I know Cache file directory is just a link or mirror to direct our PC
memory location. are those files to be able to be  saved by users ?
Please advise and Thanks


Function CheckFileAvailable(sFilePath)

    On Error Resume Next

    Dim oFS

    Dim oFile

    Set oFS = CreateObject("Scripting.FileSystemObject")

    Set oFile = oFS.OpenTextFile(sFilePath, 8, False)

    If Err.Number <> 0 Then

        CheckFileAvailable = "Fileinuse"

      ' Debug.Print "FileinUse"


        CheckFileAvailable = "Fileisfree"

       'Debug.Print "FileisFree"

    End If

End Function

Sub CopyFile2File(wkdir As String, workbookname As String, wkdir2 As String, workbookname2 As String)

Dim Fso

Set Fso = CreateObject("Scripting.FileSystemObject")

On Error GoTo Err

 Fso.CopyFile (wkdir & workbookname), wkdir2 & workbookname2  ' Change "\*.*" to "\*.xls" to move Excel Files only

 Exit Sub


 MsgBox "File path or Files not Found"



End Sub

Open in new window

Question by:duncanb7
  • 9
  • 2
  • 2
  • +1

Expert Comment

ID: 34181380
Here is a simple way to do it

WinWnd = FindWindow(METSIMCLASSNAME, vbNullString)


Loop Until WinWnd <> 0 Or Now() > tBreak

If WinWnd <> 0 Then

lpWindowName = GetWindowsCaption(WinWnd)

Debug.Print "metsim: " & lpWindowName & ", " & WinWnd

Call SetWindowPos(WinWnd, HWND_TOP, 0, 0, 0, 0, _


Wait 1

Call SendKeys("%(FO)~Y", True) ' Send File|Open command {Enter} Yes

hWndSelect = WinWnd

boolOpenWindow = False ' Don't open the window it is already open

End If

Open in new window

LVL 83

Expert Comment

by:Dave Baldwin
ID: 34181424
What do you mean by "disconnect internet"?  Browsers usually start fetching files in the background while the 'Save' dialog is open.  If it is a small file, it can finish downloading before the dialog is done.  If it's a large file, it won't be done.

You can copy any files you want from the Temporary Internet Files directory.  But IO suspect that VB is going to use the 'Temp' or 'TMP' directory for the initial download.

When it comes to downloading web sites or a lot of files, HTTrack is a good program.  You can download a whole website or just a directory.
LVL 13

Author Comment

ID: 34181486
I am able to do whole automation downloading including related API function such as Postmessag, setcursorpos, sendmessage
etc.. But I don't want to do that, if the file is in Cahce memory I can direct copy the file into my directory from Cache memory
or Temp Internet File Directory.  SInce ther is a lot ide time waiting using API function, for example, when postmessage
to  simulate click donwload button, you need to wait the Dialog window display appear...etc.

So what is simple method to get download file if the file is already in memory or temp direcoty

I mean Disconnect, I try to disconnect internet after i enter product NO and enter key
LVL 13

Author Comment

ID: 34181496
Dear R3nder,

It seems your code is more efficent  than more code, I get some question

1- GetWindowsCaption, what is for ?
2- boolOpenWindow = False ' Don't open the window it is already open

What is this of boolopenWIndow, you are able to save files without downlload window pop up

LVL 13

Author Comment

ID: 34181505
I could not find the API defination of GetWindowCaption in API function.

COuld you provide more code detail ?
LVL 83

Expert Comment

by:Dave Baldwin
ID: 34181561
The file in the cache won't necessarily have the 'correct' file name.  You would have to do a directory search to see if it's there.  

"disconnect internet"?  Are you unplugging the cable or just closing IE7 behind the file download dialog?  If any part of IE is still showing on the screen including a 'Save' dialog, then it is not disconnected or closed.
LVL 13

Author Comment

ID: 34181578
The website is embeded with  Java Applet Application and it is advance stream data system
I enter product No and press enter, and then through window to disconnect
internet that is really easy, and then click the download button  and the file can saved to
my expect. I try many time for the testing, it is no problem at all.

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

LVL 13

Author Comment

ID: 34181581
I don't close IE7 windows, just go to click start in WIndow menu and click connection icon
and disable the connection, and then enable it, the stream data is activated back
LVL 13

Author Comment

ID: 34181585
That is why I believe the data is on Cahce after I enter No and press enter key and
the testing is also proving that is pretty sure
LVL 13

Author Comment

ID: 34181592
The question is how to save the Cache memory to my expect files without through the
download popup menu that will save might be more than 5 times running time.

For example, saving 0.1 seconds for 1 file and it imply save 100 seconds for 1000 files
If you need to do 300 iteration in one day,you will save 300*100 seconds=30000
ie, equal to 30000/60=500 minutes, In other words, you will save 8.3 hours daily
LVL 13

Author Comment

ID: 34181603
After disconnection, I try open new IE7, then web but it is not able
and click connection enable, the is activate back. So you don't worry about
the testing acurracy. We focus on the Cache Memory save into file system in Windows

Accepted Solution

r3nder earned 500 total points
ID: 34181838
1 - GetWindoesCaption() - Gets the caption of the window that currently has focus
2 - boolOpenWindow = False - The window has already ben opened by the dialog box and sent on to download (that page doesnt need opening) Because you already have the file

LVL 33

Expert Comment

ID: 34182979

What are you actually trying to do?

Have you ever considered that there might be a reason why the data is displayed in an applet and is proving so difficult to download/access?

Also, have you checked you can't access the data via some other route.
LVL 13

Author Closing Comment

ID: 34281758
Thanks for all of you to reply
this mail

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

947 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

19 Experts available now in Live!

Get 1:1 Help Now