Perfishent
asked on
VBA clipboard.settext(text, [format]) method
With the clipboard.settext(text, [format]) method, how do I set the optional format to Rich Text?
ASKER
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.
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.
ASKER
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
http://support.microsoft.com/kb/150189
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.
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.
ASKER
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.
are you able to manually copy/paste the RTF textbox contents from Access into Word?
ASKER
Yes, copying manually from the Rich Text fields to Word works fine.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No one offered a viable solution.
ASKER
clipboard.SetText theText, vbCFRTF
But I get the following error:
DataObject:SetText Invalid Argument
The function works fine without the vbCFRTF argument.