Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Copy method of worksheet class failed

I have sheet which is a template for a letter to be printed.

The letter can have a variable number of list-like lines it so using the
sheet once filled and printed is problematical so I delete the sheet to be
printed and copy a new one from another sheet which has the base image.


Here is the part of the code which fails.

' If "Printwork" sheet does not exist, create it
' if it does exist, delete it first before copy.
Pwork = False
Set HH = ActiveWorkbook.Sheets
For Each Sht In HH
If LCase(Sht.Name) = "printwork" Then
Pwork = True
End If
Next
Set HH = Nothing
If Pwork = True Then
Sheets("Printwork").Delete
End If
Application.DisplayAlerts = True

' Copy printing template as "Printwork"
Application.DisplayAlerts = False
'Sheets("RenewalTemplate").Select
Sheets("RenewalTemplate").Copy Befo=Sheets(1)

and just in case it is pertinent, here is the code which prints after the
copy and sheet changes are made.

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
ActivePrinter:=""




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Copy method of worksheet class failed

I forgot to add that the failure comes after 50 copy then print cycles.

"NHRunner" wrote in message
...
I have sheet which is a template for a letter to be printed.

The letter can have a variable number of list-like lines it so using the
sheet once filled and printed is problematical so I delete the sheet to be
printed and copy a new one from another sheet which has the base image.


Here is the part of the code which fails.

' If "Printwork" sheet does not exist, create it
' if it does exist, delete it first before copy.
Pwork = False
Set HH = ActiveWorkbook.Sheets
For Each Sht In HH
If LCase(Sht.Name) = "printwork" Then
Pwork = True
End If
Next
Set HH = Nothing
If Pwork = True Then
Sheets("Printwork").Delete
End If
Application.DisplayAlerts = True

' Copy printing template as "Printwork"
Application.DisplayAlerts = False
'Sheets("RenewalTemplate").Select
Sheets("RenewalTemplate").Copy Befo=Sheets(1)

and just in case it is pertinent, here is the code which prints after the
copy and sheet changes are made.

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
ActivePrinter:=""






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Copy method of worksheet class failed

I have seen errors occur when copy of sheets is performed many times,
somewhere between 50 and 250 iterations.
Only solution seems be a .Save and maybe a Close/Open.

NickHK

"NHRunner" wrote in message
...
I forgot to add that the failure comes after 50 copy then print cycles.

"NHRunner" wrote in message
...
I have sheet which is a template for a letter to be printed.

The letter can have a variable number of list-like lines it so using the
sheet once filled and printed is problematical so I delete the sheet to

be
printed and copy a new one from another sheet which has the base image.


Here is the part of the code which fails.

' If "Printwork" sheet does not exist, create it
' if it does exist, delete it first before copy.
Pwork = False
Set HH = ActiveWorkbook.Sheets
For Each Sht In HH
If LCase(Sht.Name) = "printwork" Then
Pwork = True
End If
Next
Set HH = Nothing
If Pwork = True Then
Sheets("Printwork").Delete
End If
Application.DisplayAlerts = True

' Copy printing template as "Printwork"
Application.DisplayAlerts = False
'Sheets("RenewalTemplate").Select
Sheets("RenewalTemplate").Copy Befo=Sheets(1)

and just in case it is pertinent, here is the code which prints after

the
copy and sheet changes are made.

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
ActivePrinter:=""








  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Copy method of worksheet class failed

Thanks for the confirmation of the perceived issue.

A close/open would probably work but since I'm driving the copy/update/print
cycle from a job build memory array I would need to used a column in sheet
as the storage medium. Then drive the cycle by processing the rows and
clearing the cells that have caused a print. I hate a hack.

"NickHK" wrote in message
...
I have seen errors occur when copy of sheets is performed many times,
somewhere between 50 and 250 iterations.
Only solution seems be a .Save and maybe a Close/Open.

NickHK

"NHRunner" wrote in message
...
I forgot to add that the failure comes after 50 copy then print cycles.

"NHRunner" wrote in message
...
I have sheet which is a template for a letter to be printed.

The letter can have a variable number of list-like lines it so using
the
sheet once filled and printed is problematical so I delete the sheet to

be
printed and copy a new one from another sheet which has the base image.


Here is the part of the code which fails.

' If "Printwork" sheet does not exist, create it
' if it does exist, delete it first before copy.
Pwork = False
Set HH = ActiveWorkbook.Sheets
For Each Sht In HH
If LCase(Sht.Name) = "printwork" Then
Pwork = True
End If
Next
Set HH = Nothing
If Pwork = True Then
Sheets("Printwork").Delete
End If
Application.DisplayAlerts = True

' Copy printing template as "Printwork"
Application.DisplayAlerts = False
'Sheets("RenewalTemplate").Select
Sheets("RenewalTemplate").Copy Befo=Sheets(1)

and just in case it is pertinent, here is the code which prints after

the
copy and sheet changes are made.

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True,
ActivePrinter:=""










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
copy method of worksheet class failed Dennis Mak Excel Programming 1 July 8th 06 04:27 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 09:56 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 07:56 PM
RE :Copy method of Worksheet class failed? Steph[_3_] Excel Programming 0 April 2nd 04 11:04 PM
Copy method of Worksheet class failed? Steph[_3_] Excel Programming 1 April 2nd 04 09:52 PM


All times are GMT +1. The time now is 09:37 AM.

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"