LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
tom tom is offline
external usenet poster
 
Posts: 570
Default Code execution error

Hi all,
I have a workbook that has been running fine for a very long time. Last week
I noticed that all of a sudden I am getting an error that states "Code
execution has been interrupted". The macro still completes the operation, but
the error box comes up.
I have not altered the code in any way for quite some time, but this error
mysteriously started happening last week seemingly out of the blue. Any clues
as to what it could be and fixes for this?

Public Sub Print_Visible_Worksheets()
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim arr() As String
Dim N As Long
Const sStr As String = "Main"

For Each sh In ThisWorkbook.Worksheets
With sh
If .Visible = xlSheetVisible Then
If StrComp(.Name, sStr, vbTextCompare) Then
N = N + 1
ReDim Preserve arr(1 To N)
arr(N) = .Name
End If
End If
End With
Next sh

With ThisWorkbook
.Worksheets(arr).PrintOut
.Worksheets(1).Select <-----ERROR IS ON THIS LINE
End With
Application.ScreenUpdating = True
End Sub
 
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
Code Execution Has Been Interruptred? michael.beckinsale Excel Programming 1 October 5th 06 10:00 PM
Code Execution Error Craig Excel Programming 1 August 29th 06 09:28 AM
Macro 'Code execution has been interupted' error after print? Bluehair the Pirate Excel Programming 1 February 9th 06 06:19 PM
error: Code Execution has been interrupted Joshua Fredrickson Excel Programming 1 November 23rd 05 03:44 PM
Execution Error Craig[_8_] Excel Programming 0 September 7th 04 05:12 PM


All times are GMT +1. The time now is 02:33 PM.

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

About Us

"It's about Microsoft Excel"