Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Copy Method of WorkSheet Class Failed!

Has anybody solved this little puzzle then?
I have read a number of the threads all relating to my problem.....
Running a macro that is copying a Master Sheet then renaming that
sheet and repeating a number of times......and then erroring! The
master sheet contains a number of charts so is quite beefy to copy.
It tends to stop after 15 copies.

Is the answer to save and close after say 12 copies then
continue...does this work? or has anybody any other solutions? If you
have to save and close do you have to log out of windows to clear it's
memory out or can I just reopen and continue?

Any suggestions would be gratefully recieved.

Thanks All.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy Method of WorkSheet Class Failed!

Hi Donna

There is a example in this KB

Copying Worksheet Programmatically Causes Run-Time Error 1004
http://support.microsoft.com/default...84&Product=xlw
--
Regards Ron de Bruin
http://www.rondebruin.nl



"Donna" wrote in message om...
Has anybody solved this little puzzle then?
I have read a number of the threads all relating to my problem.....
Running a macro that is copying a Master Sheet then renaming that
sheet and repeating a number of times......and then erroring! The
master sheet contains a number of charts so is quite beefy to copy.
It tends to stop after 15 copies.

Is the answer to save and close after say 12 copies then
continue...does this work? or has anybody any other solutions? If you
have to save and close do you have to log out of windows to clear it's
memory out or can I just reopen and continue?

Any suggestions would be gratefully recieved.

Thanks All.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Copy Method of WorkSheet Class Failed!

Cheers....It looks like save and close is the fix.
I'll give it a go.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Copy Method of WorkSheet Class Failed!

Next Question then folkes....
I'm sure this must be easy....
I will be using the same copying macro with a number of files so I want
to get the ActiveWorkBook filename into a string so I can open that
String Filename. Something along the lines of..

Filename= Get Active Workbook Filename Somehow
Application.Workbooks.Open (Filename)

Any ideas?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Copy Method of WorkSheet Class Failed!

......c = ActiveWorkbook.FullName.....it was easy!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy Method of WorkSheet Class Failed!

Hi Donna

Do you want to select the files yourself or use the files in a folder

--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message oups.com...
Next Question then folkes....
I'm sure this must be easy....
I will be using the same copying macro with a number of files so I want
to get the ActiveWorkBook filename into a string so I can open that
String Filename. Something along the lines of..

Filename= Get Active Workbook Filename Somehow
Application.Workbooks.Open (Filename)

Any ideas?



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Method of WorkSheet Class Failed!

Why do you want to open the activeworkbook - it is already open.

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
.....c = ActiveWorkbook.FullName.....it was easy!



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Copy Method of WorkSheet Class Failed!

To answer all the above questions....Tom, I want to open the
activeworkbook after it has closed to try and get round the Excel bug
or only being able to copy a particular sheet a number of times before
the above quoted error occurs.....and Ron...I am in the development
phase of this particular project and I tend to change the filenames to
wip1, wip2 etx quite reguraly so I can go back to earlier versions - so
thats why I want it to detect the filename before it closes so it will
open the right file without me having to change the code all the time.

The fix mentioned in Rons...microsoft/support link does not seem to
work. I could copy and paste about 50% more files than without it but
it still errors out on me. Thankfully I will only have to go through
this pain once as I am copying a master sheet containing charts which
are duplicated for the number of measured points in the file.
Once done (hopefully) they will not need to be generated again.

Any further suggestions would be grateful as I still have a great
number of charts to generate and this is going to be tedious task if it
is going to keep failing on me.

Cheers for all the above comments. Donna

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default Copy Method of WorkSheet Class Failed!

Totally Baffled!..It comes up the copy error every 15th copy.
I've done this 3 times now (it copies 6, saves, closes then opens) and
even during third time I even copied the file from the network to the
local hard disk and continued the run from there and it still failed on
the 15th attempt....It's looking more like I'm going to have to log out
of windows every time!?!....help ..I've got alot of these to
do..........

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Method of WorkSheet Class Failed!

Sub Copy Sheets
Dim sName as String, Icounter as Long
Dim oBook as Workbook
sName = Activeworkbook.FullName
set oBook = ActiveWorkbook
For iCounter = 1 To 275
oBook.Worksheets(1).Copy After:= _
oBook.Worksheets(oBook.Worksheets.count)
'Save, close, and reopen after every 2 iterations:
If iCounter Mod 100 = 2 Then
oBook.Close SaveChanges:=True
Set oBook = Nothing
Set oBook = Application.Workbooks.Open(sName)
End If
Next
End Sub

or to do it every time

Sub Copy Sheets
Dim sName as String, Icounter as Long
Dim oBook as Workbook
sName = Activeworkbook.FullName
set oBook = ActiveWorkbook
For iCounter = 1 To 275
oBook.Worksheets(1).Copy After:= _
oBook.Worksheets(oBook.Worksheets.count)
'Save, close, and reopen after every 1 iterations:
' If iCounter Mod 100 = 2 Then
oBook.Close SaveChanges:=True
Set oBook = Nothing
Set oBook = Application.Workbooks.Open(sName)
' End If
Next
End Sub

--
Regards,
Tom Ogilvy

wrote in message
ups.com...
Totally Baffled!..It comes up the copy error every 15th copy.
I've done this 3 times now (it copies 6, saves, closes then opens) and
even during third time I even copied the file from the network to the
local hard disk and continued the run from there and it still failed on
the 15th attempt....It's looking more like I'm going to have to log out
of windows every time!?!....help ..I've got alot of these to
do..........



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 Steph[_3_] Excel Programming 2 April 7th 04 01:43 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 0 April 5th 04 11:12 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 10:15 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 09:38 PM
Copy Method of Worksheet Class Failed Steph[_3_] Excel Programming 1 April 5th 04 07:56 PM


All times are GMT +1. The time now is 09:35 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"