Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default How to test for valid 'Paste:=xlValues' before attempt.

I have code that pastes values at the current selection.
This works fine when the 'copy' is within excel.
However, occasionally the source may be from another application in which
case the 'Paste:=xlValues' fails.
Is there a way to test to see if 'Paste:=xlValues' is a valid option before
using it in the following code?
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Thank you.

Dave


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default How to test for valid 'Paste:=xlValues' before attempt.

Bassman62,

I do not know a solution to check if pastevalues is a valid operation,
however I have the following workaround

on error resume next 'If error occurs while pasting special, go to next lin
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

if err.number < 0 then
'Paste special could not be performed, perform regular paste
Activesheet.paste
end if

on error goto 0 'Reset error handling

"Bassman62" wrote:

I have code that pastes values at the current selection.
This works fine when the 'copy' is within excel.
However, occasionally the source may be from another application in which
case the 'Paste:=xlValues' fails.
Is there a way to test to see if 'Paste:=xlValues' is a valid option before
using it in the following code?
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Thank you.

Dave


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to test for valid 'Paste:=xlValues' before attempt.

Dave,

If Application.CutCopyMode = xlCopy Then
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If

HTH,
Bernie
MS Excel MVP


"Bassman62" wrote in message
...
I have code that pastes values at the current selection.
This works fine when the 'copy' is within excel.
However, occasionally the source may be from another application in which
case the 'Paste:=xlValues' fails.
Is there a way to test to see if 'Paste:=xlValues' is a valid option
before
using it in the following code?
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Thank you.

Dave




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
Sumproduct - Second Attempt Sandy Excel Worksheet Functions 4 August 10th 07 06:02 PM
Complie Error with xlValues vincent_vega Excel Programming 1 July 15th 06 07:21 PM
How to test if a workbook variable is valid Jean-Pierre Bidon Excel Programming 3 December 7th 05 04:37 PM
my first attempt at R1C1 in vba [email protected] Excel Programming 4 September 5th 05 04:32 PM
How to test if a repertory is valid Alex St-Pierre Excel Programming 2 February 17th 05 02:30 AM


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