Unformatted Paste

C

Chris Boorman

When I used Word 2003, I created a one-line macro for pasting unformatted text:


(Selection.PasteSpecial DataType:=wdPasteText),
....and I assigned it the keyboard shortcut "Ctrl+d". For me, this was truly an indispensible tool.

I now use Word 2007, and unfortunately my macro doesn't work. Word 2007 has a new feature that is supposed to make such a macro unnecessary. In the Word 2007 Advanced Options page, there are three options for pasting text.

a.. Keep Source Formatting
b.. Match Destination Formatting
c.. Keep Text Only
I've experimented with these settings, but I've found them to be too restrictive. So, I now find myself clicking "Past" on the Clipboard tab on the Home ribbon, and then "Paste Special" and then "Unformatted Text," which is cumbersome.

Can someone tell me how I can assign the unformatted paste functionality to keyboard shortcut "Ctrl+d"?



Thanks,

Chris Boorman.
 
G

Graham Mayor

The macro

Sub PasteUnfText()
On Error GoTo Oops
Selection.PasteSpecial DataType:=wdPasteText, Placement:= _
wdInLine
End
Oops:
Beep
End Sub

works in both Word 2003 and 2007
and the edit > paste special function is already assigned to ALT+CTRL+V
 
K

Klaus Linke

Hi Chris,

Word 2007 also has very nice options to set the paste options, depending on
whether you cut/copy/paste inside a doc, between docs (with the same or
different styles), or from another program.
(Office button > Word options > Advanced > Cut, copy and paste... or
something like that)

I really like those new options settings ... A macro for pasting unformatted
is still good to have in the toolbox, though :)

Regards,
Klaus
 
C

Chris Boorman

Thanks.

I'd like to have this same functionality in Outlook 2007 (i.e., when editing
an e-mail message, have the Ctrl+d shortdcut produce an unformatted paste).
Can you help me with that too?


Chris Boorman.

--------------------------------------------------------------------------------
 
C

Chris Boorman

It seems like Outlook 2007 is using Word 2007 as its editor (the same
features and dialog boxes are there), but I'm blocked from accessing the
Word object model.

* Is there a way to "unblock" access to the Word object model?
* Is there another object model that I can access?

--------------------------------------------------------------------------
 
T

Tony Jollans

I'm not quite sure what you mean by blocked, but ,,,

Outlook 2007 runs its own instance of an editor using the core of Word. It
has some functionality of its own but it is enhanced if you also have Word
2007 on the same machine. The Word Editor in Outlook runs under the
Inspector you are using at the time, and you gain access to it through ...

Application.ActiveInspector.WordEditor

(or something similar depending on exactly what you are doing). This
actually gives you a Word Document Object from where all the available parts
of the Word OM can be accessed.
 
C

Chris Boorman

Thanks Tony.

I can see the ActiveInspector object in the Outlook object model, and I can
see that it has a WordEditor property, which is of type "object," but I
can't see how to get a handle to the Word Application object?

My VBA project doesn't reference the Word library (C:\Program
Files\Microsoft Office\Office12\MSWORD.OLB), and I can't see how to do make
it do that. I figure that I've got to include the Word library in my project
in order to access its objects, don't I?

Chris.

----------------------------------------------------
 
T

Tony Jollans

The WordEditor object is a Word Document - and its Parent is the Word
Application object.

I don't have any problem adding a reference to the Word library. What
happens when you try? Or is it not listed? Or what?
 
C

Chris Boorman

I'm using Outlook's default IDE - Microsoft Visual Basic 6.5, and I can't
find any way of referencing any other library?

You say you have no difficulty adding a reference to the Word library.Are
you using Visual Studio (and not the default IDE)?


Thanks,

Chris.

---------------------------------------------------------------
 
G

Graham Mayor

From Outlook - F11 > Tools > References?

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Chris Boorman

I'm aware of Word 2007's new paste options, but I've found that they are
unsuitabled to my needs.
 
C

Chris Boorman

Pressing F11 in Outlook 2007 just moves the cursor into the "Search address
books" field. I checked the "Tools" menu, and found that there is no
"References" tab or button.I also checked "Tools > Options," and found
nothing.
 
C

Chris Boorman

I just figured it out.
Here's why I was unable to figure it out earlier:

When I sit down and start using my computer each day, for some strange
reason, a VB Editor is open on my desktop - and it's not the same one that
appears when you click "Visual Basic" from within the Outlook Editor. I had
been trying to find "Tools > References" in that version of the editor (I
don't know which version it was (it didn't even have a toolbar)).

Now that I've got the correct version of the Microsoft Visual Basic Editor
(version 6.5) in front of me, I now am able to click "Tools > References,"
and check-off the Microsoft Word 2007 Object Library.
 
W

William Chadwick

Well, now when I run the Macro from a MS Outlook email composition screen, it
pastes unformatted into the Word document I also happen to have open.

How do we write the code so that it pastes unformatted into the message
instead of finding an open Word document and pasting there?

Here's my code:

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

William
 
T

Tony Jollans

I'm not quite sure what you are doing and you aren't providing much detail,
but you need to qualify "Selection". Written as it is, without
qualification, it refers to the selection within some default window; if you
want it to work on a specific Window you must be more explicit about it.
 
W

William Chadwick

I am not a VB programmer (or VBA) or a Windows programmer. I'm actually a
Java/Actionscript/javascript programmer.

I'm not sure how to get a handle on the email that has the focus.

I want to paste unformatted in my emails with a macro tied to a keyboard
shortcut (like Ctrl + d) because sometimes I *do* want to paste formatted
(which means I don't want to make the change to never pasting unformatted).

I used that little snippit in a Word macro for several years now to paste
unformatted in emails or work. It always pasted in the document that
currently has the focus. (Selection.PasteSpecial DataType:=wdPasteText)

But now that I have started using the "new and improved" office 2007, my
little macro doesn't work.

Any help on pasting unformatted would be nice.

thanks,
William Chadwick
 
T

Tony Jollans

I'm still not quite sure what you are doing - or where your macro is - so
this is guesswork.

In office 2007 you do not use Word as the editor in Outlook. There were many
problems with it and now Outlook has its own version of the Word Editor so
that nothing you do in Word interferes with Outlook and vice-versa. I
suspect that this is at the root of your problem. If you want to run a macro
in Outlook it must be in Outlook not in Word and you have a separate Normal
Template (NormalEmail.dotm) which you may be able to use.
 
C

Chris Boorman

I finally got it working. Here it is.

Sub UPaste07()
' Pastes the Clipboard` contents as unformatted plain text.
' Replaces the old verson :
' Selection.PasteSpecial DataType:=wdPasteText

On Error GoTo Oops

Dim WordDoc As Word.Document
Dim WordApp As Word.Application

Set WordDoc = ActiveInspector.WordEditor
Set WordApp = WordDoc.Application

WordApp.Selection.PasteSpecial DataType:=wdPasteText,
Placement:=wdInLine

End

Oops:
Beep

End Sub
 
C

Chris Boorman

Now I'd like to assign this macro to Ctrl+d in the Outlook Editor. By
default, Ctrl+d is assigned to the Font dialog. Can anyone tell me how to
override that setting and re-assign Ctrl+d to a macro?


Chris.
 
S

Suzanne S. Barnhill

If you assign Ctrl+D to a macro, that setting will override the default one.
 

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