Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-20-2012, 12:32 AM
paulkaye paulkaye is offline Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2007
Advanced Beginner
Paste-As-Text macro
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default Paste-As-Text macro

I regularly need to copy and paste-as-text (rather than pasting formatting/html, etc.). In MS Word, I use the following macro:
Code:
Sub PasteSpecial()
Selection.PasteSpecial DataType:=wdPasteText
End Sub
but I get a runtime error when I try to use this in Excel. I assume there's something fundamentally different that I don't understand between the programs. At the moment I use ctrl+alt+v to bring up the paste special dialogue box, but I'd like to be able to just ctrl+shift+v to paste as plain text.
Any advice would be most appreciated.


Paul
Reply With Quote
  #2  
Old 11-20-2012, 12:50 AM
Wries Wries is offline Paste-As-Text macro Windows XP Paste-As-Text macro Office 2007
Advanced Beginner
 
Join Date: Jun 2009
Posts: 40
Wries is on a distinguished road
Default

Hello paulkaye,
please try
ActiveCell.PasteSpecial paste:=xlPasteValues

Kind regards,
Wries
Reply With Quote
  #3  
Old 11-20-2012, 01:30 AM
paulkaye paulkaye is offline Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2007
Advanced Beginner
Paste-As-Text macro
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

I got:
Runtime error '1004': PasteSpecial method of Range class failed

I am often copying from outside of Excel - could it be that paste>values is a function only for pasting from copied Excel cells?
Reply With Quote
  #4  
Old 11-20-2012, 02:28 AM
Wries Wries is offline Paste-As-Text macro Windows XP Paste-As-Text macro Office 2007
Advanced Beginner
 
Join Date: Jun 2009
Posts: 40
Wries is on a distinguished road
Default

sorry, I haven't realized you are copying outside excel.

Please try again with this and advise if it is working from your end.
Code:
Sub Paste()
ActiveCell.PasteSpecial xlPasteAll
End Sub
Kind regards,
Wries
Reply With Quote
  #5  
Old 11-20-2012, 02:44 AM
paulkaye paulkaye is offline Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2007
Advanced Beginner
Paste-As-Text macro
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

Thanks - that worked perfectly, except for one really strange problem. After I paste, undo no longer works. That is, all the 'stored' steps to which I can normally 'undo', disappear. I don't just mean that I can't undo the paste performed by the macro; I mean that all previous steps disappear from the undo list, too!
Reply With Quote
  #6  
Old 11-20-2012, 02:53 AM
Wries Wries is offline Paste-As-Text macro Windows XP Paste-As-Text macro Office 2007
Advanced Beginner
 
Join Date: Jun 2009
Posts: 40
Wries is on a distinguished road
Default

Seems normal to me. I have never been able to use undo button after running a macro.

There are some links in google regarding this issue. As far as I have read the "undo cache" is cleared after/before macro is used.
Try to google for undo macro. I have seen some, but I have no use for them so far.

Kind regards,
Wries
Reply With Quote
  #7  
Old 11-20-2012, 02:57 AM
macropod's Avatar
macropod macropod is online now Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Any running of a macro in Excel clears the Undo stack.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 11-20-2012, 03:01 AM
paulkaye paulkaye is offline Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2007
Advanced Beginner
Paste-As-Text macro
 
Join Date: Nov 2011
Posts: 84
paulkaye is on a distinguished road
Default

Wow - I've never heard of such a thing. Doesn't happen in Word, so why should it be necessary in Excel? I looked around as you suggested, and I saw the problem described in several places - and no solution. This actually means that I will not use the macro at all - no way I can risk ruining a spreadsheet for such a simple action. Oh well, thanks for your help anyway - I appreciate it.
Reply With Quote
  #9  
Old 11-20-2012, 03:53 AM
macropod's Avatar
macropod macropod is online now Paste-As-Text macro Windows 7 64bit Paste-As-Text macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

All Excel versions are the same in that respect, so I imagine it's a design limitation.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
macro, paste, text



Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste-As-Text macro Paste text box onto graph, text disappears sarasbluegroove Word 6 12-20-2016 07:22 AM
Paste-As-Text macro A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline kyjac85 Word VBA 13 09-20-2012 05:00 PM
Paste-As-Text macro Paste Special Unformatted Text kenwpaul Office 2 02-25-2011 04:53 PM
Paste-As-Text macro Macro to paste unformatted text Andacar Word 2 01-05-2011 09:15 PM
How to create macro to paste text after style? Srivas Word 0 03-16-2010 05:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft