Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Excel Files not opened

Hi,

It seems that after running the codes below in excel 2007, no files
are detected and opened from "J" path. In fact there are 4 excel files
in "J" folder that need to be opened
Does the code below miss out anything ?

Sub OpenFiles()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("J:\BBC\LO\Budget\Acad") ' Change to
suit
For Each objFile In objFolder.Files
If objFile.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=objFolder.Path & "\" & objFile.Name
'Do things
ActiveWorkbook.Close True 'or false
End If
Next
End Sub

Any help will be greatly appreciated

Thanks & Regards
Len

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Excel Files not opened

change this code : If objFile.Type = "Microsoft Excel Worksheet" Then

to this

If InStr(1, objFile.Type, "Microsoft Excel") 0 Then


"Len" wrote in message
...
| Hi,
|
| It seems that after running the codes below in excel 2007, no files
| are detected and opened from "J" path. In fact there are 4 excel files
| in "J" folder that need to be opened
| Does the code below miss out anything ?
|
| Sub OpenFiles()
| Dim objFSO As Object
| Dim objFolder As Object
| Dim objFile As Object
| Set objFSO = CreateObject("Scripting.FileSystemObject")
| Set objFolder = objFSO.GetFolder("J:\BBC\LO\Budget\Acad") ' Change to
| suit
| For Each objFile In objFolder.Files
| If objFile.Type = "Microsoft Excel Worksheet" Then
| Workbooks.Open Filename:=objFolder.Path & "\" & objFile.Name
| 'Do things
| ActiveWorkbook.Close True 'or false
| End If
| Next
| End Sub
|
| Any help will be greatly appreciated
|
| Thanks & Regards
| Len
|

  #3   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Excel Files not opened

Hi Homey,

Thanks for your reply as I just came back from holidays

After work around based on your codes, it doesn't work
Later, I found the codes below quite similar from other forums and it
works in excel 2007

If objFile.Type Like "Microsoft*Excel*Worksheet*" Then

Thanks anyway

Regards
Len



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
my excel files are being opened in Word and are unreadable Why? willy New Users to Excel 2 August 5th 06 05:49 PM
how to log all excel files opened on my pc? [email protected] Excel Programming 5 June 11th 06 07:53 PM
can't close files opened in an excel application?? urgent Excel Programming 3 September 29th 05 01:33 AM
Excel not showing last opened files Luis Verme Excel Discussion (Misc queries) 0 August 19th 05 04:20 PM
can cvs files be opened using excel viewer darriel Excel Discussion (Misc queries) 1 May 31st 05 04:15 PM


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

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

About Us

"It's about Microsoft Excel"