PastSpecial problem

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,347
Office Version
  1. 365
Platform
  1. Windows
I have this code that seemed to be working in the past, but now the users are getting an error message. if they are copying from another Excel workbook it works but if they are copying from any other source (like Notepad) they get an error

Run-Time error '1004':
PasteSpecial Method of Range class failed.

Code:
Sub PastePropVersion()
'PasteButton


Sheets("ProPricer Info").Range("D12").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False


End Sub

Thanks for the help
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Since you are pasting values only, you could skip using PasteSpecial, retrieve the text from the clipboard using the DataObject and assign the retrieved clipboard text directly to cell D12
VBA Code:
Sub PastePropVersion()
    'PasteButton
    Sheets("ProPricer Info").Range("D12").Select
    With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .GetFromClipboard
        If .GetFormat(1&) Then
            Selection = .GetText(1&)
        Else
            MsgBox "Clipboard Empty!"
        End If
    End With
    Application.CutCopyMode = False
End Sub
 
Last edited:
Upvote 1
Solution
A direct assignment should work. The reason PasteSpecial does not work for data copied from external sources is that PasteSpecial requires an Excel range.
 
Upvote 0
Since you are pasting values only, you could skip using PasteSpecial, retrieve the text from the clipboard using the DataObject and assign the retrieved clipboard text directly to cell D12
VBA Code:
Sub PastePropVersion()
    'PasteButton
    Sheets("ProPricer Info").Range("D12").Select
    With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
        .GetFromClipboard
        If .GetFormat(1&) Then
            Selection = .GetText(1&)
        Else
            MsgBox "Clipboard Empty!"
        End If
    End With
    Application.CutCopyMode = False
End Sub
Thank you
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top