LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Open files in directory

Excel 97
I use the below code to open files in 3 different directories. The first
two open in alphabetical order (the same way they are listed in the
directory). However when I use the code in the 3rd directory it seems to
open the files at random. The first two directories are on a shared
network, the 3rd is on my C drive. Can anyone tell me if there is something
I might be missing? I really need the files to open in abc order.
Any help is greatly appreciated. Thanks
Valerie

Private Sub OkButton1_Click()
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.Folder
Dim objFile As Scripting.File
Dim FullPath As String
Dim Month As String
Dim DirLoc As String
Range("n1").Select
Application.ScreenUpdating = False

Month = ComboBox1.Text
DirLoc = ComboBox3.Text
FullPath = DirLoc & "\" & Month

'Gets files from the correct directory

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(FullPath)
For Each objFile In objFolder.files

'Opens file

If objFile.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open FileName:=objFolder.Path & "\" & objFile.Name,
UpdateLinks:=True

'Prints and Exports Voc Rehab Information into the Summary Workbook

Call ExportAndPrintAllSey

ActiveWorkbook.Close
End If
Next
Application.ScreenUpdating = False
VocNorthForm.Hide
End Sub



 
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
open all files in directory davethewelder Excel Discussion (Misc queries) 2 August 26th 08 02:01 PM
Open files in the same directory houghi Excel Discussion (Misc queries) 2 May 21st 07 03:56 PM
Macro - Open all word files in a directory Dileep Chandran Excel Worksheet Functions 11 December 19th 06 02:12 PM
Open files from specific directory John Rawlins Excel Programming 1 October 16th 03 04:03 PM
Open all files in a directory Tom Waters[_2_] Excel Programming 1 September 3rd 03 12:59 PM


All times are GMT +1. The time now is 09:27 AM.

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"