• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:

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

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

Duncan

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"
    Else
        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
Err:
 MsgBox "File path or Files not Found"
 Err.Clear
 
End Sub

Open in new window

0
duncanb7
Asked:
duncanb7
  • 9
  • 2
  • 2
  • +1
1 Solution
 
r3nderCommented:
Duncan
Here is a simple way to do it
Thanks
R3nder
Do
WinWnd = FindWindow(METSIMCLASSNAME, vbNullString)
DoEvents
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, _
SWP_NOSIZE Or SWP_NOMOVE Or SWP_SHOWWINDOW)


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

0
 
Dave BaldwinFixer of ProblemsCommented:
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 http://www.httrack.com/ is a good program.  You can download a whole website or just a directory.
0
 
duncanb7Author Commented:
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
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
duncanb7Author Commented:
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

0
 
duncanb7Author Commented:
I could not find the API defination of GetWindowCaption in API function.

COuld you provide more code detail ?
0
 
Dave BaldwinFixer of ProblemsCommented:
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.
0
 
duncanb7Author Commented:
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.

0
 
duncanb7Author Commented:
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
0
 
duncanb7Author Commented:
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
0
 
duncanb7Author Commented:
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
0
 
duncanb7Author Commented:
After disconnection, I try open new IE7, then web www.yahoo.com but it is not able
and click connection enable, the yahoo.com is activate back. So you don't worry about
the testing acurracy. We focus on the Cache Memory save into file system in Windows
0
 
r3nderCommented:
Duncan
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

R3nder
0
 
NorieVBA ExpertCommented:
duncan

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.
0
 
duncanb7Author Commented:
Thanks for all of you to reply
this mail
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 9
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now