Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating Outlook Appointment

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Creating Outlook Appointment

Here is an example of a sub that makes a set of appointments where start
times are in column A and location in Column B. I set a reference to the
Microsoft Outlook object library from 'Tools References'

Sub ScheduleAppts()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appt As Outlook.AppointmentItem
Dim R As Integer
Dim X As Integer

R = Range("A65536").End(xlUp).Row

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)

For X = 1 To R
Set appt = olFolder.Items.Add
With appt
.Start = Sheets("Sheet1").Cells(X, 1).Value
.Location = Sheets("Sheet1").Cells(X, 2).Value
.Save
End With
Next X

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub


Steve
"NewBike" wrote in message
...
Hi again -
I am trying to write a macro that when a button is clicked on a
spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value &
Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Creating Outlook Appointment

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Creating Outlook Appointment

Sorry, that should be Appt.Display or Appt.Save,
not App.Display or App.Save (my first post got 'lost'!)

Anthony

"Anthony D" wrote:

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating Outlook Appointment

Thanks,
I did have the .Save statement, just didn't in the portion I cut and pasted
here. I ended up changing my data some and it works now. My Date and Time
were in separate fields, now they in one cell it works.

Now I am trying to add the user name to the body text with:

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("K7").Value
.End = Range("K7").Value
.Subject = Range("H7").Value & "/ " & Range("A7").Value & " / " &
Range("D7").Value
.Body = "Contact: " & Range("e7").Value & vbNewLine & "Contact
Phone: " & Range("F7").Value & vbNewLine & "Notified: " & Range("G7").Value
& vbNewLine & "PO Verified & Entered by: " & Environ(Username)
.ReminderSet = False
.Save
End With

Set Appt = Nothing
Set olApp = Nothing


But I am getting an Invalid Procedure call (error 5)

Any ideas?

"Anthony D" wrote:

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating Outlook Appointment

Hi Steve -
Thanks for the response!!

Two questions though:
Can you explain what you are doing with the X and R commands and I see you
are setting the Mapi folder, to the default one, but how can I set it to a
Public folder? The folder I actually want the appointments in is like a 3rd
level Public folder (Public\Division1\Shipping Calendar).


"Steve Yandl" wrote:

Here is an example of a sub that makes a set of appointments where start
times are in column A and location in Column B. I set a reference to the
Microsoft Outlook object library from 'Tools References'

Sub ScheduleAppts()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appt As Outlook.AppointmentItem
Dim R As Integer
Dim X As Integer

R = Range("A65536").End(xlUp).Row

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)

For X = 1 To R
Set appt = olFolder.Items.Add
With appt
.Start = Sheets("Sheet1").Cells(X, 1).Value
.Location = Sheets("Sheet1").Cells(X, 2).Value
.Save
End With
Next X

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub


Steve
"NewBike" wrote in message
...
Hi again -
I am trying to write a macro that when a button is clicked on a
spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value &
Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default Creating Outlook Appointment

Hi,
Thanks for your feedback.
Just a minor modification in the Environ call required,
to supply username as a string.
Environ("Username")

Hth
Anthony


"NewBike" wrote:

Thanks,
I did have the .Save statement, just didn't in the portion I cut and pasted
here. I ended up changing my data some and it works now. My Date and Time
were in separate fields, now they in one cell it works.

Now I am trying to add the user name to the body text with:

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("K7").Value
.End = Range("K7").Value
.Subject = Range("H7").Value & "/ " & Range("A7").Value & " / " &
Range("D7").Value
.Body = "Contact: " & Range("e7").Value & vbNewLine & "Contact
Phone: " & Range("F7").Value & vbNewLine & "Notified: " & Range("G7").Value
& vbNewLine & "PO Verified & Entered by: " & Environ(Username)
.ReminderSet = False
.Save
End With

Set Appt = Nothing
Set olApp = Nothing


But I am getting an Invalid Procedure call (error 5)

Any ideas?

"Anthony D" wrote:

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating Outlook Appointment

so just add a

set username as string

statement?

"Anthony D" wrote:

Hi,
Thanks for your feedback.
Just a minor modification in the Environ call required,
to supply username as a string.
Environ("Username")

Hth
Anthony


"NewBike" wrote:

Thanks,
I did have the .Save statement, just didn't in the portion I cut and pasted
here. I ended up changing my data some and it works now. My Date and Time
were in separate fields, now they in one cell it works.

Now I am trying to add the user name to the body text with:

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("K7").Value
.End = Range("K7").Value
.Subject = Range("H7").Value & "/ " & Range("A7").Value & " / " &
Range("D7").Value
.Body = "Contact: " & Range("e7").Value & vbNewLine & "Contact
Phone: " & Range("F7").Value & vbNewLine & "Notified: " & Range("G7").Value
& vbNewLine & "PO Verified & Entered by: " & Environ(Username)
.ReminderSet = False
.Save
End With

Set Appt = Nothing
Set olApp = Nothing


But I am getting an Invalid Procedure call (error 5)

Any ideas?

"Anthony D" wrote:

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Creating Outlook Appointment

Indeed yes.

Dim username As String
username = "Username"

and

Environ(username)

or

Environ("Username")

both work fine.

Anthony


NewBike wrote:
so just add a

set username as string

statement?

"Anthony D" wrote:

Hi,
Thanks for your feedback.
Just a minor modification in the Environ call required,
to supply username as a string.
Environ("Username")

Hth
Anthony


"NewBike" wrote:

Thanks,
I did have the .Save statement, just didn't in the portion I cut and pasted
here. I ended up changing my data some and it works now. My Date and Time
were in separate fields, now they in one cell it works.

Now I am trying to add the user name to the body text with:

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("K7").Value
.End = Range("K7").Value
.Subject = Range("H7").Value & "/ " & Range("A7").Value & " / " &
Range("D7").Value
.Body = "Contact: " & Range("e7").Value & vbNewLine & "Contact
Phone: " & Range("F7").Value & vbNewLine & "Notified: " & Range("G7").Value
& vbNewLine & "PO Verified & Entered by: " & Environ(Username)
.ReminderSet = False
.Save
End With

Set Appt = Nothing
Set olApp = Nothing


But I am getting an Invalid Procedure call (error 5)

Any ideas?

"Anthony D" wrote:

Hi,

With start/end date of 24/09/2006 15:00 in L7 I found that this is fine
(with reference selected to MS Outlook Object library in Tools, References)

Try App.Display or App.Save after your End With statement ?

Anthony

"NewBike" wrote:

Hi again -
I am trying to write a macro that when a button is clicked on a spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value & Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create outlook appointment Dan Wood Excel Discussion (Misc queries) 2 March 4th 10 01:31 PM
outlook appointment labels colour from excel Brettjg Excel Discussion (Misc queries) 2 March 9th 08 06:00 AM
Pass a time value from Excel to Outlook appointment splodgey Excel Discussion (Misc queries) 2 October 18th 07 11:17 AM
Can I cause Excel to post an appointment to Outlook Calendar Pat_PoulsboRV Everett Excel Programming 1 July 13th 06 03:23 AM
Automatically create outlook appointment Alarmbloke Excel Discussion (Misc queries) 0 March 12th 06 08:47 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"