Hi Rafael:
You¹re getting a compile error, probably caused by extra characters in the
code. In the code below, the RED line should not be in your code, and the
GREEN line should be a single line.
I tested your code with those changes, and it runs fine here.
If you need to split a line in VBA, use ³space, underscore² at the end of
each line, like this:
Selection.PasteAndFormat _
(wdFormatSurroundingFormattingWithEmphasis)
I try not to split lines, there¹s a dozen ³exceptions² where splitting of
lines is just not allowed under any circumstances :-)
Sub PasteUnformattedText()
'
' equivalent to Edit>Paste Special>Unformatted Text and to using
' the smart button in Word 2004 to select "keep text only"
'
Selection.PasteSpecial datatype:=wdPasteText
End Sub
Paste and Match the Formatting in the Destination Document
Sub PasteDestFormat()
'
' equivalent to using the paste options smart button in Word 2004 to
' select "match destination formatting" after pasting
'
Selection.PasteAndFormat(wdFormatSurroundingFormattingWithEmphasis)
End Sub
On 25/2/06 11:25 AM, in article
C024E3E0.1565%rafaelmontserrat@sbcglobal.net, "Rafael Montserrat"
<rafaelmontserrat@sbcglobal.net> wrote:
> Sub PasteUnformattedText()
> '
[quoted text clipped - 13 lines]
> Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
> End Sub

Signature
Please reply to the newsgroup to maintain the thread. Please do not email
me unless I ask you to.
John McGhie <john@mcghie.name>
Microsoft MVP, Word and Word for Macintosh. Consultant Technical Writer
Sydney, Australia +61 (0) 4 1209 1410
Rafael Montserrat - 25 Feb 2006 19:16 GMT
Hi John,
I went back today to make the correction and to record(?) the macro...put it
in the toolbar ready for use.
But I¹m stuck. I don¹t know if I¹ve got it right below because some thing
got added to the description, and because I don¹t know how to proceed from
here to record the macro, make it a text or icon in the toolbar.
Also, there are three commands, ³PasteUnformattedText², ³PasteDestFormat²,
and now ³Macro1², ³Macro1² having appeared after I did something, not
knowing what I was doing.
I recognize these: ³PasteUnformattedText², ³PasteDestFormat² from the
original ³Paste Special² from ³All Commands². There can also be 4 or 5
other choices in the paste special box.
Anyway I¹m stuck at this point. I know that in the past, before I moved
from OS 9 to OS 10 I got through all this and created the macro. Now I¹ve
forgotton how to complete the process.
Rafael
Below: What¹s now in the VBE(?) window.
And yes. What I got before was a ³compile error².
Sub PasteUnformattedText()
'
' equivalent to Edit>Paste Special>Unformatted Text and to using
' the smart button in Word 2004 to select "keep text only"
'
Selection.PasteSpecial datatype:=wdPasteText
End Sub
Sub PasteDestFormat()
'
' equivalent to using the paste options smart button in Word 2004 to
' select "match destination formatting" after pasting
'
Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
End Sub
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/25/06 by Rafael Montserrat
'
Application.Run MacroName:="PasteDestFormat"
ShowVisualBasicEditor = True
End Sub
On 2/24/06 11:03 PM, in article C0264C58.2F84B%john@mcghie.name, "John
McGhie [MVP - Word and Word Macintosh]" <john@mcghie.name> wrote:
> Hi Rafael:
>
[quoted text clipped - 50 lines]
>> > Selection.PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis)
>> > End Sub