View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Application Defined error

Do you really mean to copy A3 to the activesheet?

I bet that the activesheet is Sizes in Temporary.xls. And when you paste, it
fires the event.

I'd use:

dim TempWkbk as workbook
dim ActCell as Range

'where the cursor is right now!
set ActCell = Activecell

'I don't think you'll need this now
'application.enableevents = false

set tempwkbk = workbooks.open(filename:="C:\temporary.xls")
tempwkbk.worksheets("sizes").range("a3").copy _
destination:=actcell

tempwkbk.close savechanges:=false

'if you used that line from before, turn events back on
'application.enableevents = true




David P. wrote:

I have a macro that copies a range from one workbook, opens another workbook,
selects a sheet and then pastes it. Part of the code looks like this:

ChDir "C:\"
Workbooks.Open Filename:="C:\Temporary.xls"
Sheets("Sizes").Select
Range("A3").Select
ActiveSheet.Paste

It used to work. I can say that what I have changed is that I created a
Change Event in the Workbook called "Temporary". Is it getting confused by
that somehow? Thank you for your help.
--
David P.


--

Dave Peterson