Trap paste event in text box

C

chridevo

I need to strip selected html tags from text copied from MS Word into a text
box with rich text format. I have written a VBA procedure which works when I
call it by clicking on a button after paste but I would like it to run
automatically at the time of the paste event. I have looked at all the
available events on the event tab but can't find one to do this?
 
A

Allen Browne

Could you use the AfterUpdate (or Change) event of the text box to remove
any tags?

If this is A2007, PlainText() might help.
 
D

Dale Fye

Allen,

Thanks for the pointer. I've been dealing with HTML tags imbedded in
Sharepoint lists. This will be a great way to clean them up.

--
Dale

email address is invalid
Please reply to newsgroup only.
 
S

Stuart McCall

chridevo said:
I need to strip selected html tags from text copied from MS Word into a
text
box with rich text format. I have written a VBA procedure which works when
I
call it by clicking on a button after paste but I would like it to run
automatically at the time of the paste event. I have looked at all the
available events on the event tab but can't find one to do this?

TTBOMK a paste doesn't fire any of the Access events, but perhaps you could
do this differently, by grabbing the text from the clipboard instead of
waiting for a paste? Here's some code that will enable you to do that:

http://www.smccall.demon.co.uk/MiscApi.htm#Clipboard
 
C

chridevo

Allen, Thanks for the quick response. I revisited the update and change
events but neither seem to do what I need. The update event happens too late
and, in this context, the change event reminds me of a dog chasing it's tail.
I think Stuart (below) has the best approach for me.
 
C

chridevo

Stuart, Thanks very much for your reply and the code. This will be a workable
solution. For anyone interested in this thread, I have had to add to Stuart's
code to retrieve HTML (see MSDN HTML Clipboard format) and make changes to my
strip tag procedure to cope with the torrent of MS Word tags that are
retrieved using this approach.
 

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