PC Review


Reply
Thread Tools Rate Thread

Create appointment

 
 
=?Utf-8?B?RGVl?=
Guest
Posts: n/a
 
      17th Apr 2007
A couple of weeks ago I send an email asking for code to automatically set an
appointment in my calendar depending on the date in a certain cell. I want to
be reminded when a certain date arrives and I need to take an action. Bernie
was kind enough to send me the following code.

Sub CreateOutlookAppointments()
Dim OL As Object
Dim myAppt As Outlook.AppointmentItem
Dim myCell As Range

Set OL = CreateObject("outlook.application")

For Each myCell In Activesheet.Range("B1:B10")
If myCell(1,2).Value <> "Appointment added" Then
Set myAppt = OL.CreateItem(olAppointmentItem)
With myAppt
..Body = "An important reminder"
..Start = myCell.Value + 8 / 24
..Subject = "This is an important reminder"
..Save
End With
myCell(1,2).Value = "Appointment added"
End If
Next myCell

End Sub

This works but there is a problem, it will add an appointment for all the
cells in the range B1:B10, even if there is no date in the range. How would I
adapt this code so that say for example I entered a certain date in a cell
and I wanted to be reminded to take an action one week prior to the actual
date in the cell. Could I set up the maco so that I could run the macro just
on the cell that I entered the date into. That way as I enter dates I can run
the macro just for that cell. All the dates won't be entered at the same time
so I really won't know the range.

Thanks very much for any help. I am using Excel 2003.

Best regards,

Dee
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIEphY2tzb24=?=
Guest
Posts: n/a
 
      17th Apr 2007
You may have to play with this for awhile but it should give you the desired
results

Private Sub Worksheet_Change(ByVal Target As Range)
Dim OL As Object
Dim myAppt As Outlook.AppointmentItem
Dim myCell As Target

If Target.Column = 2 then

Set OL = CreateObject("outlook.application")

If Target.Value <> "Appointment added" Then
Set myAppt = OL.CreateItem(olAppointmentItem)
With myAppt
..Body = "An important reminder"
..Start = myCell.Value + 8 / 24
..Subject = "This is an important reminder"
..Save
End With
myCell(1,2).Value = "Appointment added"
End If

End if

End Sub


--
Best wishes,

Jim


"Dee" wrote:

> A couple of weeks ago I send an email asking for code to automatically set an
> appointment in my calendar depending on the date in a certain cell. I want to
> be reminded when a certain date arrives and I need to take an action. Bernie
> was kind enough to send me the following code.
>
> Sub CreateOutlookAppointments()
> Dim OL As Object
> Dim myAppt As Outlook.AppointmentItem
> Dim myCell As Range
>
> Set OL = CreateObject("outlook.application")
>
> For Each myCell In Activesheet.Range("B1:B10")
> If myCell(1,2).Value <> "Appointment added" Then
> Set myAppt = OL.CreateItem(olAppointmentItem)
> With myAppt
> .Body = "An important reminder"
> .Start = myCell.Value + 8 / 24
> .Subject = "This is an important reminder"
> .Save
> End With
> myCell(1,2).Value = "Appointment added"
> End If
> Next myCell
>
> End Sub
>
> This works but there is a problem, it will add an appointment for all the
> cells in the range B1:B10, even if there is no date in the range. How would I
> adapt this code so that say for example I entered a certain date in a cell
> and I wanted to be reminded to take an action one week prior to the actual
> date in the cell. Could I set up the maco so that I could run the macro just
> on the cell that I entered the date into. That way as I enter dates I can run
> the macro just for that cell. All the dates won't be entered at the same time
> so I really won't know the range.
>
> Thanks very much for any help. I am using Excel 2003.
>
> Best regards,
>
> Dee

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a new recurring appointment to start the day following adifferent appointment HFUK Microsoft Outlook Calendar 1 3rd Oct 2010 03:52 AM
How do I create an appointment for someone else? =?Utf-8?B?TWlrZQ==?= Microsoft Outlook Calendar 2 28th Oct 2008 09:34 PM
Can't create new appointment =?Utf-8?B?Sm9obg==?= Microsoft Outlook Calendar 2 5th Feb 2007 10:56 PM
Can I create a userform in Excel to create an appointment in Outlo =?Utf-8?B?U3Bpa2U0?= Microsoft Excel Programming 1 18th Dec 2006 09:44 AM
How to get the currently selected appointment start & enddate of a single appointment in a recurring appointment series? Fredrik Nelson Microsoft Outlook VBA Programming 0 29th Apr 2004 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:04 PM.