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

add an appointment for a custom calendar, vba excel



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 10th 09, 04:33 AM posted to microsoft.public.outlook.program_vba
Héctor Miguel
external usenet poster
 
Posts: 2
Default add an appointment for a custom calendar, vba excel

hi, all !

how is it possible (or should it be) to settle down an appointment in a custom calendar with vba ?

I have even ended up establishing a certain calendar as the current view in the OL browser
but the appointments always stay in the same calendar (the first one in the index or the original ?)
and I have not been able to find some article, topic, conversation that friendly explain this type of procedures (vba)

at the end is one of the used codes (up tp date) using late binding (just in case of several versions)

tia,
hector.

Sub Date_myCalendar()
Dim myOutlook As Object, myAppointment As Object, nRow As Integer, LRow As Integer
LRow = Range("a65536").End(xlUp).Row
On Error GoTo Create
Set myOutlook = GetObject(, "outlook.application")
If Err = 0 Then GoTo Created
Create:
Err.Clear
Set myOutlook = CreateObject("outlook.application")
Created:
On Error GoTo 0
For nRow = 2 To LRow
' in col-B are the calendar names
Set myOutlook.ActiveExplorer.CurrentFolder = _
myOutlook.Session.GetDefaultFolder(9).Folders.Item (Range("b" & nRow).Text)
Set myAppointment = myOutlook.CreateItem(1)
' in col-A are the appointment contract codes
myAppointment.Subject = "Contract code: " & Range("a" & nRow).Value
' in col-C are the dates for each appointment
myAppointment.Start = "09:00 am" & Format(Range("c" & nRow).Value, "mm/dd/yyyy")
myAppointment.End = "9:15 am" & Format(Range("c" & nRow).Value, "mm/dd/yyyy")
myAppointment.ReminderMinutesBeforeStart = 0 ' warning on appointment start
myAppointment.ReminderPlaySound = True
myAppointment.Save
Next
' myOutlook.Quit
Set myAppointment = Nothing
Set myOutlook = Nothing
End Sub


Ads
  #2  
Old June 10th 09, 02:32 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default add an appointment for a custom calendar, vba excel

Using CreateItem() to create an item always adds that item to the default
folder for that type of item, not whichever folder is currently selected.

You can either create the item in the default folder and then move it to the
desired target folder, or you can get the target folder's Items collection
and call that collection's Add() method to add the item directly to that
target folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Héctor Miguel" wrote in message
...
hi, all !

how is it possible (or should it be) to settle down an appointment in a
custom calendar with vba ?

I have even ended up establishing a certain calendar as the current view
in the OL browser
but the appointments always stay in the same calendar (the first one in
the index or the original ?)
and I have not been able to find some article, topic, conversation that
friendly explain this type of procedures (vba)

at the end is one of the used codes (up tp date) using late binding (just
in case of several versions)

tia,
hector.

Sub Date_myCalendar()
Dim myOutlook As Object, myAppointment As Object, nRow As Integer, LRow
As Integer
LRow = Range("a65536").End(xlUp).Row
On Error GoTo Create
Set myOutlook = GetObject(, "outlook.application")
If Err = 0 Then GoTo Created
Create:
Err.Clear
Set myOutlook = CreateObject("outlook.application")
Created:
On Error GoTo 0
For nRow = 2 To LRow
' in col-B are the calendar names
Set myOutlook.ActiveExplorer.CurrentFolder = _
myOutlook.Session.GetDefaultFolder(9).Folders.Item (Range("b" &
nRow).Text)
Set myAppointment = myOutlook.CreateItem(1)
' in col-A are the appointment contract codes
myAppointment.Subject = "Contract code: " & Range("a" & nRow).Value
' in col-C are the dates for each appointment
myAppointment.Start = "09:00 am" & Format(Range("c" & nRow).Value,
"mm/dd/yyyy")
myAppointment.End = "9:15 am" & Format(Range("c" & nRow).Value,
"mm/dd/yyyy")
myAppointment.ReminderMinutesBeforeStart = 0 ' warning on appointment
start
myAppointment.ReminderPlaySound = True
myAppointment.Save
Next
' myOutlook.Quit
Set myAppointment = Nothing
Set myOutlook = Nothing
End Sub


  #3  
Old June 11th 09, 03:10 AM posted to microsoft.public.outlook.program_vba
Héctor Miguel
external usenet poster
 
Posts: 2
Default add an appointment for a custom calendar, vba excel

hi, Sir !

Thanks so much, Ken, that did the trick vg

regards,
hector.

Ken Slovak - [MVP - Outlook] wrote in message ...
Using CreateItem() to create an item always adds that item to the default folder for that type of item
not whichever folder is currently selected.

You can either create the item in the default folder and then move it to the desired target folder
or you can get the target folder's Items collection and call that collection's Add() method to add the item directly to that target folder.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


hi, all !

how is it possible (or should it be) to settle down an appointment in a custom calendar with vba ?

I have even ended up establishing a certain calendar as the current view in the OL browser
but the appointments always stay in the same calendar (the first one in the index or the original ?)
and I have not been able to find some article, topic, conversation that friendly explain this type of procedures (vba)

at the end is one of the used codes (up tp date) using late binding (just in case of several versions)

tia,
hector.

Sub Date_myCalendar()
Dim myOutlook As Object, myAppointment As Object, nRow As Integer, LRow As Integer
LRow = Range("a65536").End(xlUp).Row
On Error GoTo Create
Set myOutlook = GetObject(, "outlook.application")
If Err = 0 Then GoTo Created
Create:
Err.Clear
Set myOutlook = CreateObject("outlook.application")
Created:
On Error GoTo 0
For nRow = 2 To LRow
' in col-B are the calendar names
Set myOutlook.ActiveExplorer.CurrentFolder = _
myOutlook.Session.GetDefaultFolder(9).Folders.Item (Range("b" & nRow).Text)
Set myAppointment = myOutlook.CreateItem(1)
' in col-A are the appointment contract codes
myAppointment.Subject = "Contract code: " & Range("a" & nRow).Value
' in col-C are the dates for each appointment
myAppointment.Start = "09:00 am" & Format(Range("c" & nRow).Value, "mm/dd/yyyy")
myAppointment.End = "9:15 am" & Format(Range("c" & nRow).Value, "mm/dd/yyyy")
myAppointment.ReminderMinutesBeforeStart = 0 ' warning on appointment start
myAppointment.ReminderPlaySound = True
myAppointment.Save
Next
' myOutlook.Quit
Set myAppointment = Nothing
Set myOutlook = Nothing
End Sub



 




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
How to attach a custom appointment form to a public calendar Irina Outlook - Using Forms 1 March 6th 09 03:25 PM
Custom View for Outlook Calendar - Date/Time of next appointment Walter Mitchell Pelowski Outlook - Calandaring 0 February 12th 09 04:58 AM
Custom View for Outlook Calendar - Date/Time of next appointment Walter Mitchell Pelowski Outlook - Calandaring 0 February 12th 09 04:54 AM
Can I create custom field in the Calendar Appointment view? wajie Outlook - Calandaring 3 December 10th 08 08:53 PM
outlook 2003 macro to extract calendar appointment info to Excel CPOjoe Outlook - Calandaring 3 July 15th 08 04:04 PM


All times are GMT +1. The time now is 10:26 AM.


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