#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Wen Query Issue

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Wen Query Issue

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Wen Query Issue

Thanks Joel

Yes. it sometimes works, but when I repeat web query more times it dose not
work. After I delete the temporary internet files, it works again, but this
does not sovle my problem, since my web qurey will run many times, in which
the code was wrotteb by VBA in excel. Is there a way to delete temporary
internet files from VBA code when each time I start to run web query?

Minghui

"Joel" wrote:

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Wen Query Issue

Temporary Internet files are stored in the following directory on my PC. You
can find the exact location by going into options on Internt explorer where
you delete temporary internet files and view files. To see these files you
must change you window explorer settings to view possible system files.

C:\Documents and Settings\Joel\Local Settings\Temporary Internet Files

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "c:\temp\abc.txt"


to delete all files in a directory

Folder = "C:\Documents and Settings\Joel\Local Settings\Temporary Internet
Files\"
Set fs = CreateObject("Scripting.FileSystemObject")

FName = Dir(Folder & "*.*")
Do while FName < ""
fs.DeleteFile Folder & FName
FName = Dir(
loop





"Hans" wrote:

Thanks Joel

Yes. it sometimes works, but when I repeat web query more times it dose not
work. After I delete the temporary internet files, it works again, but this
does not sovle my problem, since my web qurey will run many times, in which
the code was wrotteb by VBA in excel. Is there a way to delete temporary
internet files from VBA code when each time I start to run web query?

Minghui

"Joel" wrote:

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Wen Query Issue

Hi Joel

Thanks for your help. The code is great, but it does not help me to delete
all htm files from Temporary Internet Files. When run the program with the
code you suggested, it cannot find any file to delete. In fact, the files
are under sub directory of Content.IE5 which there are some random sub
folders names to store htm files, If I set path with C:\Documents and
Settings\userid\Local Settings\Temporary Internet Files\Content.IE5\ , we can
only find one file: index.dat, this file is not allowed to delete. How can I
delete those htm files under sub directories?

Thanks for your help

Hans

"Joel" wrote:

Temporary Internet files are stored in the following directory on my PC. You
can find the exact location by going into options on Internt explorer where
you delete temporary internet files and view files. To see these files you
must change you window explorer settings to view possible system files.

C:\Documents and Settings\Joel\Local Settings\Temporary Internet Files

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "c:\temp\abc.txt"


to delete all files in a directory

Folder = "C:\Documents and Settings\Joel\Local Settings\Temporary Internet
Files\"
Set fs = CreateObject("Scripting.FileSystemObject")

FName = Dir(Folder & "*.*")
Do while FName < ""
fs.DeleteFile Folder & FName
FName = Dir(
loop





"Hans" wrote:

Thanks Joel

Yes. it sometimes works, but when I repeat web query more times it dose not
work. After I delete the temporary internet files, it works again, but this
does not sovle my problem, since my web qurey will run many times, in which
the code was wrotteb by VBA in excel. Is there a way to delete temporary
internet files from VBA code when each time I start to run web query?

Hans

"Joel" wrote:

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Wen Query Issue

Try this code. It is a recursive algorithm that will search all sub folders.

Sub GetWorksheets()

strFolder = "C:\Documents and Settings\Joel\Local Settings\Temporary
Internet Files"

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set Folder = _
fso.GetFolder(strFolder)

Call GetWorksheetsSubFolder(strFolder + "\")
End Sub

Sub GetWorksheetsSubFolder(strFolder)
Set fso = CreateObject _
("Scripting.FileSystemObject")

Set Folder = _
fso.GetFolder(strFolder)

If Folder.subfolders.Count 0 Then
For Each sf In Folder.subfolders
On Error GoTo 100
Call GetWorksheetsSubFolder(strFolder + sf.Name + "\")
100 Next sf
End If
'folder size in bytes
On Error GoTo 200
For Each fl In Folder.Files
If Right(UCase(fl.Name), 4) = ".HTM" Then
fso.DeleteFile strFolder & fl.Name
End If
Next fl

200 On Error GoTo 0

End Sub


"Hans" wrote:

Hi Joel

Thanks for your help. The code is great, but it does not help me to delete
all htm files from Temporary Internet Files. When run the program with the
code you suggested, it cannot find any file to delete. In fact, the files
are under sub directory of Content.IE5 which there are some random sub
folders names to store htm files, If I set path with C:\Documents and
Settings\userid\Local Settings\Temporary Internet Files\Content.IE5\ , we can
only find one file: index.dat, this file is not allowed to delete. How can I
delete those htm files under sub directories?

Thanks for your help

Hans

"Joel" wrote:

Temporary Internet files are stored in the following directory on my PC. You
can find the exact location by going into options on Internt explorer where
you delete temporary internet files and view files. To see these files you
must change you window explorer settings to view possible system files.

C:\Documents and Settings\Joel\Local Settings\Temporary Internet Files

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "c:\temp\abc.txt"


to delete all files in a directory

Folder = "C:\Documents and Settings\Joel\Local Settings\Temporary Internet
Files\"
Set fs = CreateObject("Scripting.FileSystemObject")

FName = Dir(Folder & "*.*")
Do while FName < ""
fs.DeleteFile Folder & FName
FName = Dir(
loop





"Hans" wrote:

Thanks Joel

Yes. it sometimes works, but when I repeat web query more times it dose not
work. After I delete the temporary internet files, it works again, but this
does not sovle my problem, since my web qurey will run many times, in which
the code was wrotteb by VBA in excel. Is there a way to delete temporary
internet files from VBA code when each time I start to run web query?

Hans

"Joel" wrote:

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Web Query Issue

Thanks Joel

Your new code is work for my case after I add line

On Error Resume Next

into For Each condition code

i.e.

For Each fl In Folder.Files

If Right(UCase(fl.Name), 4) = ".HTM" Then
On Error Resume Next
fso.DeleteFile strFolder & fl.Name
End If
Next fl

If I do not add this line, when find any htm file which is being using by
another person or program, the program will stop For Each condition. and it
goes to next sub folder, i.e. the rest of htm files in current sub folder
will be not deleted.

Thanks again for your help. You sovle my problem

Hans

"Joel" wrote:

Try this code. It is a recursive algorithm that will search all sub folders.

Sub GetWorksheets()

strFolder = "C:\Documents and Settings\Joel\Local Settings\Temporary
Internet Files"

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set Folder = _
fso.GetFolder(strFolder)

Call GetWorksheetsSubFolder(strFolder + "\")
End Sub

Sub GetWorksheetsSubFolder(strFolder)
Set fso = CreateObject _
("Scripting.FileSystemObject")

Set Folder = _
fso.GetFolder(strFolder)

If Folder.subfolders.Count 0 Then
For Each sf In Folder.subfolders
On Error GoTo 100
Call GetWorksheetsSubFolder(strFolder + sf.Name + "\")
100 Next sf
End If
'folder size in bytes
On Error GoTo 200
For Each fl In Folder.Files
If Right(UCase(fl.Name), 4) = ".HTM" Then
fso.DeleteFile strFolder & fl.Name
End If
Next fl

200 On Error GoTo 0

End Sub


"Hans" wrote:

Hi Joel

Thanks for your help. The code is great, but it does not help me to delete
all htm files from Temporary Internet Files. When run the program with the
code you suggested, it cannot find any file to delete. In fact, the files
are under sub directory of Content.IE5 which there are some random sub
folders names to store htm files, If I set path with C:\Documents and
Settings\userid\Local Settings\Temporary Internet Files\Content.IE5\ , we can
only find one file: index.dat, this file is not allowed to delete. How can I
delete those htm files under sub directories?

Thanks for your help

Hans

"Joel" wrote:

Temporary Internet files are stored in the following directory on my PC. You
can find the exact location by going into options on Internt explorer where
you delete temporary internet files and view files. To see these files you
must change you window explorer settings to view possible system files.

C:\Documents and Settings\Joel\Local Settings\Temporary Internet Files

Set fs = CreateObject("Scripting.FileSystemObject")
fs.DeleteFile "c:\temp\abc.txt"


to delete all files in a directory

Folder = "C:\Documents and Settings\Joel\Local Settings\Temporary Internet
Files\"
Set fs = CreateObject("Scripting.FileSystemObject")

FName = Dir(Folder & "*.*")
Do while FName < ""
fs.DeleteFile Folder & FName
FName = Dir(
loop





"Hans" wrote:

Thanks Joel

Yes. it sometimes works, but when I repeat web query more times it dose not
work. After I delete the temporary internet files, it works again, but this
does not sovle my problem, since my web qurey will run many times, in which
the code was wrotteb by VBA in excel. Is there a way to delete temporary
internet files from VBA code when each time I start to run web query?

Hans

"Joel" wrote:

Can you open the file using the same URL in your internet explorer?

"Hans" wrote:

When do Web Query in Excel, got the problem with the file could not be
accessed, What is this problem? How to solve it?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Query/ODBC issue Jombe Excel Discussion (Misc queries) 0 September 7th 07 09:08 PM
Web Query Formatting Issue... Jambruins Excel Discussion (Misc queries) 0 June 28th 07 04:00 PM
Find date query and Display issue VBA Noob Excel Worksheet Functions 2 July 14th 06 11:23 PM
Need help with an 'Edit Query' issue. ken.kimbrell Excel Discussion (Misc queries) 2 May 8th 06 08:48 PM
Query and/or 3D Referencing Issue BonnieRone Excel Discussion (Misc queries) 0 January 6th 06 06:01 PM


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"