View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Copy & Paste - Unsafe?

Sorry, I cant answer that question because it is not something that I have
ever experienced.

You can reduce the possibility of such an occurrence by adding:

Application.CutCopyMode=False to Clear The Clipboard after pastespecial
instruction.

Better still, try and avoid using copy & thus by-pass using the clipboard
altogether using an approach like following:

ringmaster.value = rngAllocation.Value

--
jb


"Nick H" wrote:

Hi, I'm hoping that an MVP can help settle a dispute (and save me some
reprogramming).

I have written a consolidation routine that takes data from a number
of formatted workbooks and consolidates it into a single 'Master_Data'
sheet.

As the code loops through each source workbook it defines the area to
be copied then copies and pastes it to the Master_Data sheet using the
following 2 lines of code...

rngAllocation.Copy

rngMaster.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, SkipBlanks:=False, Transpose:=False

During a code review, a colleague pointed out that this was unsafe
because another Excel application could be running at the same time on
the dual processor server and use the Windows paste buffer between my
code's copy and paste buffer operations, causing my code to paste the
wrong information.

I've never heard of this happening. Is there a slight risk?

Best regards, Nick H