remove font designation before copying to clipboard?

  • Thread starter Mickey Ferguson
  • Start date
M

Mickey Ferguson

This may not be the right forum in which to ask this question, but I'll try
here anyway. I've got a VB6 application that copies text into the
clipboard:

Clipboard.SetText sMsg

I read the documentation in MSDN, which states that if an optional, second
parameter, Format, is not supplied, the default format to copy the text is
Text (in other words, not RichText or DDE. When I then go to another
application (Microsoft Word 2003) and paste the clipboard contents into a
table, it pasts in the font from my VB app, not preserving the existing
table's font. Am I doing something wrong? Is there some property I can set
on the table in Word 2003 so that the font will remain constant? Or maybe I
need to change the way I put the text onto the clipboard within my VB app?
 
H

Herb Tyson [MVP]

I would think that your best option would be to use Paste Special -
Unformatted Text when pasting into Word. Something like this:

Selection.PasteSpecial link:=False, DataType:=wdPasteText
 
M

Mickey Ferguson

Herb, thank you very much for your reply! In the word document, I'm not
doing it programmatically. I'm just using the general purpose paste -
literally, Ctrl-V, to insert the text. Is there a way to do that
non-programmatically?
 
S

Suzanne S. Barnhill

Edit | Paste Special as Unformatted Text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
 
H

Herb Tyson [MVP]

Or... if you want a keystroke for it, assign the following macro to a
keystroke:

Sub PasteUnformatted()
'
' PasteUnformatted Macro
' Macro recorded May 31, 2000 by Herbert L. Tyson
'
Selection.PasteSpecial link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
End Sub


As you can see by the date, I've been using this solution for quite a long
time. ;-)

--
Herb Tyson MS MVP
Author of the Word 2007 Bible
Blog: http://word2007bible.herbtyson.com
Web: http://www.herbtyson.com
 
M

Mickey Ferguson

Thanks, Herb (and Suzanne, previously). It turns out that I also discovered
that when I pasted the text into my table, even if I did an unformatted
method as previously recommended, it still changed the text alignment within
each cell. I've figured out a slightly different approach that really does
solve my needs. I created a macro that can format an entire table to the
exact layout I need, and it's even extensible enough that it will go through
whatever portion of the document I have selected, and apply my desired
layout (cell width, font, paragraph/cell justification, etc.) to all tables
within the selection region, leaving all non-table areas completely
untouched. So now I just go ahead and paste the normal way throughout the
entire document, and then when I'm done, I select the entire document and
apply my macro, fixing up all tables at once. Herb, your original idea of
using a macro to do what I wanted programmatically was definitely the seed
that planted the idea. Thanks to all!
 

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