LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default By-passing clipboard message

You would usually add Jake's line of code before you close your workbook. But
since you do your paste after you close the workbook, that won't work for your
existing code.

But this did:

Option Explicit
Sub testme01()
Selection.SpecialCells(xlCellTypeLastCell).Select
Range(Selection, Cells(1)).Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Range("A1").Select
ActiveSheet.Paste
End Sub

But I think I'd take a slightly different approach. You rely on the window to
be active when you close one workbook to be open to the worksheet where you want
to paste.

If you could specify the "from" worksheet and the "to" worksheet, then you could
do something like this:

Option Explicit
Sub testme01B()

Dim FromWks As Worksheet
Dim ToWks As Worksheet

Set FromWks = ActiveSheet
Set ToWks = Workbooks("book2").Worksheets("sheet1")

With FromWks
.Range("a1", .Cells.SpecialCells(xlCellTypeLastCell)).Copy _
Destination:=ToWks.Range("a1")

Application.CutCopyMode = False
.Parent.Close savechanges:=False 'true '????
End With

End Sub

Ian M wrote:

Thanks Jake

However I'm not sure exactly where I should put you line of code in my
macro.

My macro is:

Selection.SpecialCells(xlCellTypeLastCell).Select
Range(Selection, Cells(1)).Select
Selection.Copy
ActiveWorkbook.Close
Range("A1").Select
ActiveSheet.Paste

I've tried putting your line before or after but it doesn't seem to
work. I must be doing something wrong?

Thanks again for your help.

Kind regards

Ian M

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


--

Dave Peterson

 
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
Message: 'Cannot empty clipboard' Terry Pinnell Excel Discussion (Misc queries) 2 May 27th 09 09:11 AM
Message: Cannot empty clipboard Terry Pinnell Excel Discussion (Misc queries) 2 May 22nd 09 12:39 AM
Error message: Cannot empty the clipboard. Carolyn Excel Discussion (Misc queries) 1 December 27th 06 07:28 PM
Error Message: Cannot Empty the Clipboard Prema New Users to Excel 0 January 2nd 06 10:02 PM
Error Message "Cannot Empty Clipboard" Robert Setting up and Configuration of Excel 1 September 17th 05 12:29 AM


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