VBA clipboard.settext(text, [format]) method

With the clipboard.settext(text, [format]) method, how do I set the optional format to Rich Text?
PerfishentAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PerfishentAuthor Commented:
I've tried this:

clipboard.SetText theText, vbCFRTF

But I get the following error:

DataObject:SetText Invalid Argument

The function works fine without the vbCFRTF argument.
0
PerfishentAuthor Commented:
I found this article that documents the SetText( StoreData [, format]) method:

http://msdn.microsoft.com/en-us/library/office/ee414786(v=office.12).aspx

But the article doesn't say how to set up the optional format argument.
0
PerfishentAuthor Commented:
This article says there's a bug with the vbCFRTF constant and that you have to use &hBF01 instead. I tried this, and the settext() funciton did not work at all. It didn't throw an error, but it didn't paste anything into the document at all.

http://support.microsoft.com/kb/150189
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

aikimarkCommented:
The first link uses a Dataobject, probably a MSForms object.  This is different that the Clipboard object.
Here are VBA code examples of early and late binding.
http://desmondoshiwambo.wordpress.com/2012/02/23/how-to-copy-and-paste-text-tofrom-clipboard-using-vba-microsoft-access/

Note: You can also use the Windows API to get to/from the clipboard.

I'm not sure in what environment you are in.  Some of the Office products' VBA environments can invoke application or some application.object methods of getting data into and out of the clipboard.
0
PerfishentAuthor Commented:
I understand how to use the clipboard and the settext() method. These are working fine in my program. The problem I'm having is that I need to take text from a Rich Text memo field in Access and paste it into Word while preserving the Rich Text formatting. The settext() method has an optional parameter called "format." I'd like to set that parameter to Rich Text to see if that will preserve the formatting from the memo field when I paste the text into Word. Right now, when I paste the text into Word, Word displays the formatting tags instead of the formatting itself. I haven't been able to find any accurate documentation on how to set the format to Rich Text.
0
aikimarkCommented:
are you able to manually copy/paste the RTF textbox contents from Access into Word?
0
PerfishentAuthor Commented:
Yes, copying manually from the Rich Text fields to Word works fine.
0
PerfishentAuthor Commented:
I never could get the clipboard.settext() method to preserve the rich text formatting entered into the Memo fields in Access. I had to change the fields to plain text in order to get the application to work correctly.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PerfishentAuthor Commented:
No one offered a viable solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.