Charlotte Foust
cfoust at infostatsystems.com
Thu Apr 14 11:27:21 CDT 2005
I think what you're looking for is an autokeys macro. You can find info in Help using the AutoKeys search word. The name of each autokey macro is a ^x syntax, which represents the combination of control key and letter to press to trigger the macro. The macro can use a SendKeys to insert the desired text at the cursor position. Charlotte Foust -----Original Message----- From: Steve Erbach [mailto:erbachs at gmail.com] Sent: Thursday, April 14, 2005 9:13 AM To: Access Developers discussion and problem solving Subject: [AccessD] A2000: Inserting HTML codes into a Text Box Dear Group, This is far from urgent. I'm simply trying to make it easier for a client. I've set up a form for my client to add news items to a web page I put together for her. There are text boxes for a date, a title for the item, and for the text of the news item itself. That text box is called txtNewsItem. There, of course, is no formatting in a text box; but I'd like to give my client the option to insert the proper HTML codes for bold, italic, underline, line break, etc. I could give her a cheat sheat with a few of the codes listed and how to type them in properly, but I'd like to go a little further. Is there a way for, say, the <b></b> codes to be inserted in a text box with a keystroke like Ctrl-B? I've been experimenting with SendKeys and OnKeyUp. I discovered that the SendKeys action itself triggers the OnKeyUp event; so a bit of code like this in the On Key Up event procedure does NOT work properly: Private Sub NewsItem_KeyUp(KeyCode As Integer, Shift As Integer) If Shift And acCtrlMask Then Select Case KeyCode Case Asc("B"), Asc("b") SendKeys "<b></b>" ... etc. So I moved the SendKeys to a Click event procedure of a button off to the side of the txtNewsItem text box...but when I use code like this: Private Sub cmdBold_Click() Screen.PreviousControl.SetFocus SendKeys "<b></b>" ... the HTML codes are placed at the END of the text in the box. The cursor position is lost when the button is clicked. Ideally I'd like the user to be able to select a block of text and press Ctrl-B and have the HTML <b> and </b> codes appear surrounding the selected text. Is this even possible? Regards, Steve Erbach Scientific Marketing Neenah, WI www.swerbach.com Security Page: www.swerbach.com/security -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com