Re: position cursor in body
From: Dean (Dean_at_discussions.microsoft.com)
Date: 09/24/04
- Next message: Dean: "Re: position cursor in body"
- Previous message: Richard Lewis Haggard: "Lost ability to bring up Macros"
- In reply to: Nick Hill: "Re: position cursor in body"
- Next in thread: Dean: "Re: position cursor in body"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 24 Sep 2004 07:25:08 -0700
Nick,
vbend takes the cursor to the end of the selected line, but your current
code does not affect cursor position. I'm using Outlook 2000 and your
ActiveExplorer code didn't work for me. I think the code below does what you
need. Note that this code should only be executed from the task item, not
from the visual basic editor.
Sub Insert_Datestamp()
Dim objitem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set objitem = myOlApp.Inspectors.Item(1).CurrentItem
mylocation = InputBox("The cursor is currently located in the:" &
Chr(10) & "1: Subject" & Chr(10) & "2: Body")
'Tasks open with the cursor in the Subject area
With objitem
'Uncomment the line below if an input box is an acceptable way to
enter updates; otherwise, I think the code below does what you need.
'myupdate = InputBox("Enter update here.")
.Body = Str$(Date) + vbTab + "-" + vbTab + myupdate + vbNewLine +
.Body
' **NEED CODE HERE TO MOVE CURSOR TO END OF LINE**
'I assume you mean the end of the line just inserted instead of the
end of the body? "HERE" is at the end of the body.
'If you prefer to just be in the edit mode, use the addition below
End With
If mylocation = 1 Then
SendKeys "{tab 8}{end}" 'Do not run this from within Visual Basic Editor
or the keys sent will be sent to the editor, not the task. This takes the
cursor from the Subject area to the end of the first line of the body.
Else
SendKeys "^{home}{end}" 'This takes the cursor from anywhere in the body
area to the end of the first line of the body.
End If
End Sub
"Nick Hill" wrote:
> Thanks for the reply, firstly it is the body of currently open TASK item
> I want to datestamp, not a mail.
>
> Second, you are absolutely right - I want to insert the date into the
> currently open task, not the currently selected one (although I should
> imagine in most cases this will be the same thing). Basically, I want to
> be able to open a task, click a toolbar button, or use an accelerator,
> and insert into the top line todays date and a 'gap' so I can then enter
> an update for that task. What I have so far is almost there (other than
> the cursor position).
>
> However, if the way I am doing it is not 'clean' I can only say it is my
> first ever attempt at VB in Outlook, and I am definately open to
> suggestions!!!
>
> Cheers,
> Nick
>
>
> > Are you sure you want to do that for the currently *selected* , not
> > the currently *displayed* message (ActiveExplorer vs ActiveInspector)?
> > Note that if the message has any formatting, it will be lost as you
> > are reading and setting the plain text body.
> > For the currently selected message, there is really no such thing as
> > the current cursor postion. Even if you mean the preview pane, the
> > cursor position makes no sense as you cannot type in the preview pane.
> > If you want to modify the currently dislplayed message and position
> > the cursor, you might want to use the SafeInspector object exposed by
> > the Redemption library:
> > http://www.dimastr.com/redemption/safeinspector.htm
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
>
- Next message: Dean: "Re: position cursor in body"
- Previous message: Richard Lewis Haggard: "Lost ability to bring up Macros"
- In reply to: Nick Hill: "Re: position cursor in body"
- Next in thread: Dean: "Re: position cursor in body"
- Messages sorted by: [ date ] [ thread ]