PDA

View Full Version : Place Cursor At End Of Message



DLancy
06-08-2004, 01:56 PM
Ok, so I'm able to get my template placed in correctly with the look I want when a user presses a button. Only problem is that after the code is added, the message box is at the top of the message. I'd like to be at the bottom of the message (where the new template has been inserted) and even better if the focus is in the Message with the cursor at the end. The only method that I've seen for this is Activate, but I can't find an Inspector for the actual message box, just the Message tab. Any ideas?

Thanks again,
Doug

SJ McAbney
06-09-2004, 02:17 AM
I've never seen any coding in Outlook but, if it is like other Office applications in its usage of VBA then you should look up the SelStart proeprty.

jamescol
06-09-2004, 10:32 AM
Here is some code that will place the insertion point at the end of the text in a textbox


TextBox1.SelStart = TextBox1.TextLength
TextBox1.SetFocus

DLancy
06-15-2004, 08:52 AM
Can't get that to work in Outlook with the Message Body.

Still looking for a solution.

stefri
06-15-2004, 12:38 PM
DLancy,
I do not really understand what you want to do.

What do you call the message box? msgbox or the message body?
I am afraid you cant set the insertion point in a message body unless you are using Word as editor (dreamboat: what about inserting somewhere in the text?)

Stefri

Anne Troy
06-15-2004, 12:55 PM
Yeah, we can do end of story in Word...

Selection.EndKey Unit:=wdStory

Thanks for stopping in, Stefri!!

DLancy
06-15-2004, 01:37 PM
Well, I've finally got it to focus into the message of the form, but I haven't found a way to move it to the end yet.

Thanks for the continued help.

-Doug


sub CommandButton_click()
Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set objControl = objPage.Controls("Message")
objControl.SetFocus
end sub

stefri
06-15-2004, 01:56 PM
did you try SendKeys after setting focus using Ctrl-End to move to the end of the text
SendKeys "^{END}"
stefri

DLancy
06-15-2004, 02:24 PM
Sounds like that would do it, but I keep getting the following error:

Type mismatch: 'SendKeys'
Any idea why?

Thanks,
Doug


Sub CommandButton_click()
Set objPage = Item.GetInspector.ModifiedFormPages("Message")
Set objControl = objPage.Controls("Message")
objControl.SetFocus
SendKeys "^{END}"
End Sub

Zack Barresse
06-17-2004, 12:07 PM
Hi,

I think you need the Application bit preceeding it. Can you use:

Application.SendKeys "^{END}"


Does that help?

jamescol
06-17-2004, 01:16 PM
Are you sure you are using VBA? Some of your syntax looks more like VBScript. Is this a customization of an existing form or a form you created from scratch with VBA?

DLancy
06-21-2004, 07:00 AM
Application.SendKeys does not work.

I would guess it is a customization of an existing form.

I started this process through the Outlook menus Tools > Forms > Design a Form...
and chose the message form to begin with. So does that mean all my script is VBScript?

Would I be better off doing this another way and what tools would I need to do that.

Thanks,
-Doug

jamescol
06-21-2004, 12:55 PM
Yeah you're using VBScript instead of VBA, which is why some of the code isn't working as expected. That's not to say you can't do what you want, but we need to find out if someone can help with the VBScript - that's not my strong point.

Any VBScripters here?

jamescol
06-21-2004, 01:02 PM
Oh - as for another method. You could use VBA if you can't get VBScript to do what you need. The tradeoff is with deployment. Designing the form the way you are now makes it easy to publish it to your users. If you choose the VBA route, you'll lose any centralized management of the form, and will have to dance around the end-user installation.

To use VBA, press ALT-F11 to bring up the VBA Editor. Unlike other Office apps that store code in an individual document, all OL VBA code is stored in one project called VBAProject.OTM. To insert a form, Just select Insert | UserForm. Same thing for modules.

For centralized, more complex Outlook forms, folks generally use VB6 or VS .Net to create an Add-in.

Cheers,
James

stefri
06-22-2004, 01:20 PM
Application can be found in the Item object
Try Item.Application.SendKeys
If we are lucky....
stefri

DLancy
06-23-2004, 07:01 AM
No luck. :(

Nice try though! :)

stefri
06-23-2004, 12:16 PM
I wonder if this is even possible....
Quite disappointed about item.application.sendkeys
stefri

jamescol
07-04-2004, 10:10 PM
While re-reading this thread, I wondered whether or not you ever tried adding the line


objControl.SelStart = objControl.TextLength + chr(13)


before the


objControl.SetFocus


If not, give that a try and let us know what happens.

Cheers,
James

jamescol
07-20-2004, 11:01 PM
Hi Doug,
Were you ever able to get this to work?

Cheers,
James