Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.crashesgpfs
external usenet poster
 
Posts: 1
Default Copy generates an automation error.

Hi, everybody

The following code works just one time. If It runs again without
exiting Excel it generates an automation error. Why ? Any workaround ?
Is there a problem with tyhe Copy method ?

Public Sub Atry()
'***
Dim aw As Workbook
Set aw = ActiveWorkbook
Workbooks.Open "c:\temp.xls"
ActiveSheet.Copy After:=aw.Sheets(aw.Sheets.Count) '<-- This were the
problem is
Windows("temp.xls").Close
Set aw = Nothing
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.crashesgpfs
external usenet poster
 
Posts: 27,285
Default Copy generates an automation error.

The code ran several times for me with no problem, so there is nothing wrong
with the code. If there is a problem, it must be related to you
workbooks/environment. Perhaps you have hidden sheets or something in the
destination workbook which are causing the problem - it would be hard to
tell.

--
Regards,
Tom Ogilvy

"Richard" wrote in message
om...
Hi, everybody

The following code works just one time. If It runs again without
exiting Excel it generates an automation error. Why ? Any workaround ?
Is there a problem with tyhe Copy method ?

Public Sub Atry()
'***
Dim aw As Workbook
Set aw = ActiveWorkbook
Workbooks.Open "c:\temp.xls"
ActiveSheet.Copy After:=aw.Sheets(aw.Sheets.Count) '<-- This were the
problem is
Windows("temp.xls").Close
Set aw = Nothing
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
Hyperlink selection generates error message cwpauline Links and Linking in Excel 2 October 18th 08 04:04 AM
2003 macro generates compiler error on 2007 KenInPortland Excel Worksheet Functions 2 September 2nd 08 09:45 PM
Closing Excel user form generates error Ken Warthen Excel Discussion (Misc queries) 0 October 10th 07 08:30 PM
cutting and pasting rows from one sheet to another generates error JT Spitz Excel Discussion (Misc queries) 7 February 14th 06 07:06 PM
Excel Analysis Add-in EOMONTH generates #NAME? error Ray Excel Worksheet Functions 6 July 18th 05 07:00 PM


All times are GMT +1. The time now is 11:33 AM.

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"