View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default Workbook.Open fail in 2003, good in XP

Excel XP & Win XP
I'm helping an OP. He has Excel 2003 Pro.
He and I have now run the code shown below several times on both our
computers. His computer fails on the "Set wb = Workbooks.Open.........."
line every time.
Note that the code is looking for a .csv file. The Temp folder has a bunch
of those. It also has one .xls file. We both changed the ".csv" to ".xls"
in the below code and ran the code again.
In ALL cases, the file opens on my computer and NEVER opens on his.
The error is always on the "Set wb..." line.
My question: Why does this code fail on his computer and not on mine?
Thanks for your time. Otto
Sub testopen()
ThePath = "C:\Temp\"
ChDir ThePath
TheFile = Dir("*.csv")
Application.DisplayAlerts = False
Set wb = Workbooks.Open(ThePath & TheFile)
Application.DisplayAlerts = True
End Sub
PS: I sent him the entire file, so it's not a case of copy/paste.