A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Insert date at cursor location



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 20th 09, 12:10 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook,microsoft.public.outlook.program_vba
F.H. van Zelm
external usenet poster
 
Posts: 14
Default Insert date at cursor location

Hi,

Once, I had a macro to inert the current date anywhere in the notes field of
an open item.
That macro has ... gone with the wind.

I recreated:
=====================================
Sub DateInsert()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Body = Date & vbCr & myItem.Body
Set myItem = Nothing
Set myOlApp = Nothing
End Sub

=====================================
It works but, of course, inserts the date on top of any text.

What to write to make the time stamp appear at the cursor?

Many thanks, Frans
www.fhvzelm.com


Ads
  #2  
Old July 20th 09, 01:10 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook,microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Insert date at cursor location

In what kind of item? In what version of Outlook?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"F.H. van Zelm" wrote in message
...
Hi,

Once, I had a macro to inert the current date anywhere in the notes field
of an open item.
That macro has ... gone with the wind.

I recreated:
=====================================
Sub DateInsert()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Body = Date & vbCr & myItem.Body
Set myItem = Nothing
Set myOlApp = Nothing
End Sub

=====================================
It works but, of course, inserts the date on top of any text.

What to write to make the time stamp appear at the cursor?

Many thanks, Frans
www.fhvzelm.com



  #3  
Old July 20th 09, 01:48 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook,microsoft.public.outlook.program_vba
F.H. van Zelm
external usenet poster
 
Posts: 14
Default Insert date at cursor location

Hi Sue,

Outlook 2003, 'stand alone', not server * client

My former code worked on any type of item: contact, appointment, mail.
It would insert the current date at the cursor.

Annoyance with my 'new' code is also that it gives the security warning
whereas my former code worked without.

Kind regards, Frans


"Sue Mosher [MVP]" schreef in bericht
...
In what kind of item? In what version of Outlook?

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"F.H. van Zelm" wrote in message
...
Hi,

Once, I had a macro to inert the current date anywhere in the notes field
of an open item.
That macro has ... gone with the wind.

I recreated:
=====================================
Sub DateInsert()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Body = Date & vbCr & myItem.Body
Set myItem = Nothing
Set myOlApp = Nothing
End Sub

=====================================
It works but, of course, inserts the date on top of any text.

What to write to make the time stamp appear at the cursor?

Many thanks, Frans
www.fhvzelm.com





  #4  
Old July 20th 09, 09:13 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook,microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Insert date at cursor location

A statement like this

Dim myOlApp As New Outlook.Application

should never appear in an Outlook VBA macro. Instead, to avoid security
prompts, you need to use the intrinsic Application object:

Set myOlApp = Application

The Outlook object model itself has no techniques for inserting data at the
insertion point. For mail/post items, your options depend on whether you're
using the Outlook editor or the Word editor. For other items, you can try
automating the toolbar commands using code like that at
http://www.outlookcode.com/threads.a...messageid=6872, but I
haven't had good results with that myself. Or, use the methods of the
SafeInspector object from the third-party Outlook Redemtion library.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

ms,
"F.H. van Zelm" wrote in message
...
Hi Sue,

Outlook 2003, 'stand alone', not server * client

My former code worked on any type of item: contact, appointment, mail.
It would insert the current date at the cursor.

Annoyance with my 'new' code is also that it gives the security warning
whereas my former code worked without.

Kind regards, Frans


"Sue Mosher [MVP]" schreef in bericht
...
In what kind of item? In what version of Outlook?


"F.H. van Zelm" wrote in message
...
Hi,

Once, I had a macro to inert the current date anywhere in the notes
field of an open item.
That macro has ... gone with the wind.

I recreated:
=====================================
Sub DateInsert()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Body = Date & vbCr & myItem.Body
Set myItem = Nothing
Set myOlApp = Nothing
End Sub

=====================================
It works but, of course, inserts the date on top of any text.

What to write to make the time stamp appear at the cursor?

Many thanks, Frans
www.fhvzelm.com







  #5  
Old July 21st 09, 04:13 PM posted to microsoft.public.office.developer.outlook.vba,microsoft.public.outlook,microsoft.public.outlook.program_vba
Alan Moseley
external usenet poster
 
Posts: 61
Default Insert date at cursor location

What about this?

Public Sub InsertDate()
SendKeys Date()
End Sub

It's a bit pants and you might want to do some checking before the sendkeys
runs, but it might work for you.
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"F.H. van Zelm" wrote:

Hi,

Once, I had a macro to inert the current date anywhere in the notes field of
an open item.
That macro has ... gone with the wind.

I recreated:
=====================================
Sub DateInsert()
Dim myOlApp As New Outlook.Application
Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.Body = Date & vbCr & myItem.Body
Set myItem = Nothing
Set myOlApp = Nothing
End Sub

=====================================
It works but, of course, inserts the date on top of any text.

What to write to make the time stamp appear at the cursor?

Many thanks, Frans
www.fhvzelm.com



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert date at cursor location F.H. van Zelm Outlook - General Queries 4 July 21st 09 04:13 PM
Insert Date - Format Text / Cursor Location srm Outlook - Using Forms 5 September 8th 08 11:41 AM
Insert date in Notes ?? Synapse Syndrome[_2_] Outlook - General Queries 5 June 1st 08 01:34 PM
how can i insert date in the signal? chelsea Add-ins for Outlook 1 December 22nd 07 08:36 PM
Outlook 2003 cursor location default Roibn L Taylor Outlook - Using Contacts 2 January 17th 06 08:21 PM


All times are GMT +1. The time now is 02:33 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright 2004-2014 Outlook Banter.
The comments are property of their posters.