Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for Paste Unformatted in Word 2000 1

Status
Not open for further replies.

fishey

Instructor
Oct 30, 2002
24
US
I have written a macro in WordXP/Word2003 that simply does a Paste Special - Unformatted. This macro works fine; however, one of our users has Word 2000, and the macro causes an error on his computer. Can anyone tell me how to modify this macro to work on Word 2000:

Sub PasteUnformatted()
Selection.PasteSpecial Link:=False, DataType:=wdPasteText
End Sub

Thanks in advance for your help.
 
I'm still using Word 97, and that code runs fine on my computer. Something specific to that PC, perhaps?

VBAjedi [swords]
 
It runs fine if I click Tools-Macro-Macros, choose the "PasteUnformatted" macro and click Run. However, when I attach it to a button, it will not run.

The computer is a laptop with a docking station that its user plugs it into while at work. I am using it at work, and I have placed the macro into the "Normal" template. Does any of this information help?
 
How is it "attached to a button"? Did you paste the code directly into the button's Click event? That might cause problems.

Try leaving the code in a normal sub, and just calling the sub with the button. To set that up, just put your worksheet into Design mode, double-click the button (which should bring up the VBA editor with the cursor in the button's click event area), then put this single line there:

PasteUnformatted

That should call the sub when the button is clicked.

VBAjedi [swords]
 
When you say "put your worksheet in Design mode," are you aware I am using Word 2000? I thought worksheets were in Excel. In any event, I don't know how to go into Design mode. The way I attached the button to Word's Standard Toolbar is this: I right-click on the toolbar and choose "Customize"; then under "Commands," I click on "Macros" (under Categories), then drag the macro from the "Commands" column up to the toolbar.
 
Hi fishey,

I have just done exactly as you describe and it works fine for me in Word 2K (on Win XP) - what is the error you get?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
My bad on the "worksheet" reference - meant to say "document" (most of the questions I answer relate to Excel so I have Excel stuff on the brain!).

When you said "attach it to a button" I figured you were referring to a button you had inserted into your document from the Controls Toolbar. But from your last post I gather you are using a custom menu button. In that case you have a different issue - unless you are adding the button on the fly using VBA code, the button won't appear when you open the file on other computers. So the weakness of that approach is that you have to set up each computer manually. That's probably the source of the problem on the 2000 machine.

You could either attach the code to a button in the document (which will transfer with the document to other PC's), or you could add code to the document that adds that macro to the desired toolbar when the document is opened (the more "pro" approach, but just a bit more involved.


VBAjedi [swords]
 
What about a global template? I used to manage a system a few years ago where I used global templates for that kind of item. It worked out great because I found that I could create and modify macros anytime, and then just let users know that the next time they login, they'll have new stuff.
 
Never seen that before, Slove7 - have a star! Looks promising. . . how about it, fishey?

VBAjedi [swords]
 
Thanks to everyone who has contributed to this inquiry!!! I have a wealth of information to try out. The workstation where I was getting the error message has not been available to me for the last few days. As soon as I am able to get a few minutes on the specific problem computer, I will try your suggestions. I have every confidence that I should be able to successfully accomplish creation of the "Paste Unformatted" button, thanks to your help.

'Preciate it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top