View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Nick H[_3_] Nick H[_3_] is offline
external usenet poster
 
Posts: 48
Default xlPasteValues is also pasting Formats

It seems there are two distinctly different PasteSpecial operations -
one for pasting from an external session or thread and another for
internal (local?) copy&pasting. I couldn't figure out a way of
querying the clip-board to find out the source of its contents but, in
case it helps anyone else, I've come up with this 'fudge' that works
for my purposes (beware of line-wrap)...

On Error Resume Next
'This next line will run without error only if copying from an
EXTERNAL thread/session/workbook
ActiveSheet.PasteSpecial Format:="Text", _
Link:=False, _
DisplayAsIcon:=False

'This next line will run without error only if copying from an
INTERNAL session
Selection.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlNone, _
SkipBlanks:=False, _
Transpose:=False
On Error GoTo 0