View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Fredrik Wahlgren Fredrik Wahlgren is offline
external usenet poster
 
Posts: 339
Default copy from closed workbook again! ;(



"Christy" wrote in message
...
I have the following code which works perfectly on my office computer. I
sent it to the co-worker I made it for who is attached to the LAN and it
crashes on the line:

ChDrive MyPath

Does anyone have any idea what the problem is or how I can fix it. We
commented out that line and it crashed on the next on and we commented out
that line and it crashed on the next one.


Sub GetDataFromClosedWB()
Dim SaveDriveDir As String, MyPath As String
Dim FName As Variant

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

SaveDriveDir = CurDir
MyPath = Application.DefaultFilePath 'or use "C:\Data"
ChDrive MyPath
ChDir MyPath
FName = Application.GetOpenFilename(filefilter:="Excel Files, *.xls")

If FName = False Then
'do nothing
Else

'Get Fridays date and Office city/state/zip
GetData FName, "Saturday", "b1:b2", Sheets("Source").Range("b2"),
False
GetData FName, "Saturday", "b2:b3", Sheets("Source").Range("b3"),
False

End If

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

ChDrive SaveDriveDir
ChDir SaveDriveDir
End Sub



Wouldn't it make sense to use an error handler and then show the error
description?

/Fredrik