Jump to content

Recommended Posts

Posted (edited)

Hi,

I have written a short piece of VBA code for outlook using bits of code I have found on the internet and assigned it to a button on the toolbar, with the aim that when I want to update the task I click the button to run the code that then creates a timestamp, and a solid line to signify a new entry.

 

However, when I run it I would like to get the cursor to position itself at the start of the main text body for me to start typing. I have tried

objItem.Move wdstory, -1

but it doesn't work, hence turning it into a comment. Does anyone know how to modify this so that the cursor positions itself correctly so that when I click the button I can just start typing without having to click the start of the main text body?

 

Many thanks,

 

James

 

Sub StampDate()
   Dim objOL As Outlook.Application
   Dim objNS As Outlook.NameSpace
   Dim objItem As Object
   Dim strStamp As String
   On Error Resume Next
   Set objOL = Application
   Set objItem = objOL.ActiveInspector.CurrentItem
   If Not objItem Is Nothing Then
       Set objNS = objOL.Session
       strStamp = Now & " - " & objNS.CurrentUser.Name
       objItem.Body = vbCrLf & vbCrLf & strStamp & vbCrLf & "____________________________________________________" & vbCrLf & objItem.Body
      ' objItem.Move wdstory, -1
   End If
   objItem.Body.Select
   Set objOL = Nothing
   Set objNS = Nothing
   Set objItem = Nothing
End Sub

Edited by Gronwold

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...