Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Strange, code works on one computer but not another

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Strange, code works on one computer but not another

Mr Whiz...

Windows Explorer only shows one file in the folder. I delete all of the
files, run Access to generate the files and the problem still exists. How
can there be more than one file with the same name in the folder anyway?

???

Thanks for any additional ideas.

Joel

"JLGWhiz" wrote:

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

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

You are correct that there should not be two files of the same name in a
folder, but it sounds like the program is opening a second instance of the
file rather than the same file twice. If that is in fact, what is happening,
then something on the maverick computer is causing your SQL to think it has
not finished the job. That is the type of thing you have to look for when
trouble shooting. I have seen files with the same name in the same folder,
with different extensions.

"Joel" wrote:

Mr Whiz...

Windows Explorer only shows one file in the folder. I delete all of the
files, run Access to generate the files and the problem still exists. How
can there be more than one file with the same name in the folder anyway?

???

Thanks for any additional ideas.

Joel

"JLGWhiz" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Strange, code works on one computer but not another

What do you get just using VBA built in Dir() ?

NickHK

"Joel" wrote in message
...
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





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
Works on one computer, but not another Beric Dondarrion Excel Discussion (Misc queries) 4 November 25th 09 08:46 PM
Excel 2007 strange behavior on two computer kurlisue Excel Discussion (Misc queries) 1 April 21st 08 09:21 PM
New Computer HPVAL no longer works macgron Excel Worksheet Functions 3 February 12th 07 05:52 PM
Autocomplete works with my home computer but not the office computer Andy Excel Discussion (Misc queries) 4 December 11th 04 07:21 PM
formatting in macro works on one computer Heather[_3_] Excel Programming 2 July 8th 03 10:35 PM


All times are GMT +1. The time now is 12:53 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"