简体   繁体   中英

Trying to change selected text format in MS Access rich text field

I've been trying to find a solution for an MS Access 2007 application I'm building for work. One of the forms allows for creation of a particular kind of document, with the main body of the text being a rich text field. What I'd like to do is have the ability to select a section of text and then press a formatting button and cause the selected text to change - not unlike the submission box here, in fact. I'm pretty solid in Access and VBA, and have tried using SelText and so on, but I just can't seem to get it to work.

Can anyone shed any light on how I could go about this? I know I could just use keyboard shortcuts, but the database is aimed at people whose computer skills are relatively minimal.

Thanks in advance to anyone who can help!

You are on the right way ;)

If I were you, i would create buttons like on this site (with B for bold and I for italic), the user can select text and click on the buttons.

Now, for making the selected text bold, use

RichTextBox.SelBold = True
'or just toggle the value
RichTextBox.SelBold = Not RichTextBox.SelBold

for italic:

RichTextBox.SelItalic = True

for colors:

RichTextBox.SelColor = vbRed

and so on...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM