How can I reformat the clipboard and/or a DataObject in VBA for Word 2003?

M

M Shafaat

Hi,
How can I reformat the clipboard and/or a DataObject in VBA for Word 2003?



Regards
Mohammad
 
J

Jay Freedman

Hi,
How can I reformat the clipboard and/or a DataObject in VBA for Word 2003?



Regards
Mohammad

You cannot "reformat" the clipboard from VBA. And the only part of the
DataObject that you can access from VBA is plain text without any
formatting (as a String object).

You can use VBA to format or reformat a range in a document *after*
you've pasted the clipboard contents there. If necessary, this can be
done in a new blank document that the macro creates, uses, and then
closes without saving.
 
K

Karl E. Peterson

Jay said:
You cannot "reformat" the clipboard from VBA.

You could (through the API) read the clipboard, manipulate that data, wipe the
clipboard, and restore new data to it, though. I kinda/sorta do that with my
ConClip tools (http://vb.mvps.org/tools/ConClip), to actually "strip" the formatting
off the clipboard. This is essentially the same as, but far easier than, pasting
into Notepad and copying back out. (I use it so often, that I actually keep an icon
on my Desktop to clean the clipboard with a doubleclick!) You'd have to be pretty
nutz to take that to the next level, and try messing with the "rich" formats,
though. <g>
 
J

Jay Freedman

Karl said:
You could (through the API) read the clipboard, manipulate that data,
wipe the clipboard, and restore new data to it, though. I
kinda/sorta do that with my ConClip tools
(http://vb.mvps.org/tools/ConClip), to actually "strip" the
formatting off the clipboard. This is essentially the same as, but
far easier than, pasting into Notepad and copying back out. (I use
it so often, that I actually keep an icon on my Desktop to clean the
clipboard with a doubleclick!) You'd have to be pretty nutz to take
that to the next level, and try messing with the "rich" formats,
though. <g>

That's pretty much what I meant by pasting into a blank Word document,
reformatting, (forgot to mention copying back to the clipboard), and closing
without saving. But I read the original post as wanting to change the
formatting of the clipboard contents while it's still in the clipboard.
That's not gonna happen, at least not in VBA.
 
K

Karl E. Peterson

Jay said:
That's pretty much what I meant by pasting into a blank Word document,
reformatting, (forgot to mention copying back to the clipboard), and closing
without saving. But I read the original post as wanting to change the
formatting of the clipboard contents while it's still in the clipboard.
That's not gonna happen, at least not in VBA.

Yep, no can do. It's read-only or write-only. No read/write access allowed.
 

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