Can not run Macro written in Excel 2003 on Excel 2002

W

WayneF

Hi all,

I have recorded the following Macro ....

Sub Paste_TSR()
'
' Paste_TSR Macro
' Macro recorded 27/01/2005 by WayneF
'

'
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

Basically it just paste's the clip board content's to the given position
with out pasting this formulas. The problem is when I try to use this file
in Excel 2000 or Excel 2002 I get this error ...

Run-time error '1004':
PasteSpecial method of Range class failed

When I go to the debug the following selection is highlighted ...

Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

I guess its some kind of compatibility problem ... Can anyone help me to
over come this.

I hope I have been precise enough

Cheers,

Wayne
 
G

Gord Dibben

Wayne

As written your macro will not work in either 2003 or 2002 for me.

You need something to paste.

Add Selection.Copy before the first Selection.PasteSpecial line.


Gord Dibben Excel MVP
 
B

Bernie Deitrick

Wayne,

This was a bug in XL2000/02, where xlPasteColumnWidths was never defined.
Instead, you need to use the hardcoded value 8 as the option to pastespecial

HTH,
Bernie
MS Excel MVP
 
W

WayneF

Hi Gord,

I dont want to define the copy part, The user should go and start the
copy and then position the cursor at the paste area and just hit the button.
The I want the values and NOT the formula pasted.

P.S. It works fine in 2003 just not in porevios version

Thanks for your help !

Cheers,

Wayne
 
W

WayneF

Cheers Bernie,

Your years of hard work have payed of for me :)

Thanks a lot for your help, Just got it working a treat !

Cheers,

Wayne
 
G

Gord Dibben

Gotcha.

I read it as if you were just copying in place.

I see Bernie's zeroed in on the problem.


Gord
 
D

Dave Peterson

Fixed in xl2002, actually.

Bernie said:
Wayne,

This was a bug in XL2000/02, where xlPasteColumnWidths was never defined.
Instead, you need to use the hardcoded value 8 as the option to pastespecial

HTH,
Bernie
MS Excel MVP
<<snipped>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top