View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Strange, code works on one computer but not another

On the computer that opens the WB a second time, use Windows Explorer to see
if you have two instances of the WB saved to the folder.

"Joel" wrote:

TIA:

When I run code below on one computer works fine (cycles through all files
in the folder once)...another computer the code opens and cycles through all
files in the folder but opens the first file a second time and then stops.
If I delete the first file in the folder, all is OK, the code cycles through
all files once and stops. The files in the folder are created and exported
from Access.

Same versions of software (2003) and windows on both computers. How can
this be???

Thanks,

Joel

Sub OpnFilesNew()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object


Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("c:\Copper") 'change directory
For Each objFile In objFolder.Files
If objFile.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=objFolder.Path & "\" & objFile.Name

'do stuff

Workbooks(objFile.Name).Save
Workbooks(objFile.Name).Close True 'saves changes
End If
Next
End Sub