View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Steve Steve is offline
external usenet poster
 
Posts: 1,814
Default Macro stops after opening a file

I'm using MS Office 2003 and Windows XP PRO

Have a scenario that is quite puzzling, after opening a
particular file (.xls) the macro just stops. However, if I set a
break on the open statement and then do nothing other than hit F5 to continue
processing the macro completes as intended and generates the desired results.
If I set a break on the following "If Err.Number" statement processing never
reaches it. I use the exact same process in opening several other files with
no problems? I modified the macro to open this particular file that has 7
worksheets all of which are empty and now it stops after it opens the file.
Any ideas, thanks in advance for your efforts. By the way, I don't have
access to the PC that the macro is on which is why I typed the short example
of the problem. I believe in debugging the problem I set On Error Resume
Next, but I can't be 100% sure.

Sub Main()

Call openallfiles

End Sub


Sub openallfiles

Dim runpthname As String
Dim invwkbname As String

runpthname = "c:\computername\myname\subdirectory\anotherdirect ory\"
invwkbname = "Inventory.xls"

' If I set a break here and hit F5 the macro completes
workbooks.open filename:= runpthname & invwkbname

' If I set a break here it never reaches it?????
If Err.number < 0 Then
MsgBox ("Error occurred in opening file: " & invwkbname)
End If

End Sub