Stop Word from inserting a table.

G

Guest

Wow MS word can sure drive a person crazy sometimes. Is there any way to
stop it from trying to 'help' me? What I am doing is creating a macro that
will paste text and do a simple find and replace. When I do it manually it
works fine, even when I record the macro. However when I run the macro,
instead of unformatted text, I get a table! I didn't say anything in the
macro about a table and I don't want it.

One thing I notice is that after doing a Paste Special -> Unformatted text
Word seems to call this wdPasteDefault. What is going on and why won't Word
just do as I ask it to and no more?

Thanks for any help I may recieve

Sub Try3_to_paste_and_format()
'
' Try3_to_paste_and_format Macro
' Macro recorded 20/04/2005 by me
'
Selection.PasteAndFormat (wdPasteDefault)
Selection.WholeStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^t"
.Replacement.Text = ","
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
 
G

Guest

I have sorted this out on my own. The problem was that Word didn't seem to
recognize the difference between paste and paste special. I changed
Selection.PasteAndFormat (wdPasteDefault)
to
Selection.PasteSpecial DataType:=wdPasteText, Link:=False

and everything was fixed. Now problem is to get it to stop asking if I'd
like to start the search over again from the beginning...

Jay
 
D

Daiya Mitchell

Always state your version of Word.

I don't know anything about the table, or the code in general, but I'm
fairly certain recent versions of Word have a bug where it mis-records the
process Edit|Paste Special| Unformatted Text.
Selection.PasteAndFormat (wdPasteDefault)

So I think that line is wrong. Word does record correctly if you use the
Paste Options button to "keep text only", in which case you get:

Selection.PasteAndFormat (wdFormatPlainText)

Though there are other ways to code the command to paste unformatted text.

Start there, and see if that helps.
 

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