Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Macro stops after opening a file

Try trapping you error this way:

Sub openallfiles()

Dim runpthname As String
Dim invwkbname As String

On Error GoTo openallfiles_Error

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




Exit Sub

openallfiles_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ")"

End Sub


--
Steve

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


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

AltaEgo,

Thanks for providing your suggestion. When I ran it guess what. The file
opened and the macro stopped. Same condition. I then set a break on the "On
Error" statement and walked through the code and no errors were detected.
However, based on another suggestion I received, which was to set a delay
just before opening the file, a delay of 2 seconds using the Timer function
seems to have done the trick. Why I'm not exactly sure, but it does. Thanks
again for your efforts.

"AltaEgo" wrote:

Try trapping you error this way:

Sub openallfiles()

Dim runpthname As String
Dim invwkbname As String

On Error GoTo openallfiles_Error

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




Exit Sub

openallfiles_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ")"

End Sub


--
Steve

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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 245
Default Macro stops after opening a file

Thank you for the feedback.

--
Steve

"Steve" wrote in message
...
AltaEgo,

Thanks for providing your suggestion. When I ran it guess what. The file
opened and the macro stopped. Same condition. I then set a break on the
"On
Error" statement and walked through the code and no errors were detected.
However, based on another suggestion I received, which was to set a delay
just before opening the file, a delay of 2 seconds using the Timer
function
seems to have done the trick. Why I'm not exactly sure, but it does.
Thanks
again for your efforts.

"AltaEgo" wrote:

Try trapping you error this way:

Sub openallfiles()

Dim runpthname As String
Dim invwkbname As String

On Error GoTo openallfiles_Error

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




Exit Sub

openallfiles_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & ")"

End Sub


--
Steve

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



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
Macro stops when one a file Steve Excel Programming 2 June 15th 09 01:11 PM
VBA just stops when opening a macro workbook MSweetG222 Excel Programming 10 March 24th 09 11:18 PM
Opening a csv file stops macro Prema Excel Programming 4 February 1st 08 03:19 PM
Opening a file stops a Macro Bob Myers Excel Worksheet Functions 2 January 8th 08 11:50 PM
Macro stops running after file has moved LWhite Excel Programming 1 January 4th 05 07:44 PM


All times are GMT +1. The time now is 10:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"