PDA

View Full Version : Process works in debug



bassnsjp
06-12-2009, 01:11 PM
Using MS Office 2003 and Windows XP PRO

Have a scenario that is quite puzzling, in that when I'm opening a particular file 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 desired results. By the way, the file does open, but all processing stops. If I set a break on the following IF Err.Number statement processing never reaches it. Any ideas anyone, thanks in advance for your efforts. I use the exact same process in opening several other files with no problems. ???? :banghead: :help

I don't have connectivity to the PC that has the code so I have to type in a short example.


sub Main()

call openallfiles

end sub


sub openallfiles

dim runpthname as string
dim invwkbname as string

runpthname = "c:\computername\myname\subdirectory\anotherdirectory\"
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

Simon Lloyd
06-12-2009, 01:19 PM
Your macro does nothing except open the workbook if it exists at that path, if you are not getting errors have you used On Error Resume Next somewhere?
Underneath your workbooks.open statement puts this:
MsgBox "Workbook path is " & ActiveWorkbook.Path _
& vbLf & " Workbook name is " & ActiveWorkbook.Nameand see what you get.

bassnsjp
06-12-2009, 06:43 PM
Simon,

I don't have access to the computer that has the complete macro which is why I only typed in a very small condensed version of what the macro does.

I'm not at work so I'm not able to try it, but I did a similar thing by setting a breakpoint on the "If" statement and it never reach it. Instead the macro just stops or goes into some suspend state, not sure which. When I put the breakpoint on the workbooks.open statement the process breaks as it does for debug then I just press F5 to continue and the macro completes with no problems. Strange.

I will give your suggestion a try, but I believe I'm going to run into the same situation. Thanks for your help.

Steve