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  dBforums > PC based Database Applications > Microsoft Excel > Create Appointments in Outlook with Excel Macro.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-06-10, 13:19
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Create Appointments in Outlook with Excel Macro.

Hi All,

I have got the below macro which loops through the rows in a sheet and schedules appointments in outlook in as per my requirement but I have following issues with the below macro.

1) I want to know how I can also add the Label along with the .Body, Subject, Location etc.. Label is usually used to define colours for appointments for e.g. Important, Business, Personal etc.

2) I want to know how I can insert / copy a long text with some URL/links in it and a data table on my appointment body. I have all data in a excel sheet in a name range. .i.e. "Mailbodytext". This range is quit big .i.e. from Cell A1:X55. It's properly formatted. I want to copy this range along with formatting without gridlines on my appointment body.

Code:
Option Explicit

' requires a reference to the Microsoft Outlook x.0 Object Library
Sub RegisterAppointmentList()
' adds a list of appontments to the Calendar in Outlook
Dim olApp As Outlook.Application
Dim olAppItem As Outlook.AppointmentItem
Dim r As Long
'Dim myrange As String
'myrange = Range("myrange").Value
    DeleteTestAppointments ' deletes previous test appointments
    On Error Resume Next
    Set olApp = GetObject("", "Outlook.Application")
    On Error GoTo 0
    If olApp Is Nothing Then
        On Error Resume Next
        Set olApp = CreateObject("Outlook.Application")
        On Error GoTo 0
        If olApp Is Nothing Then
            MsgBox "Outlook is not available!"
            Exit Sub
        End If
    End If
    r = 10 ' first row with appointment data in the active worksheet
    While Len(Cells(r, 1).Formula) > 0
        Set olAppItem = olApp.CreateItem(olAppointmentItem) ' creates a new appointment
        With olAppItem
            ' set default appointment values
            .Start = Now
            .End = Now
            .Subject = "No subject"
            .Location = ""
            .Body = ""
            .ReminderSet = True
            .BusyStatus = olFree
            .RequiredAttendees = ""
            
            
            ' read appointment values from the worksheet
            On Error Resume Next
            .Start = Cells(r, 1).Value + Cells(r, 2).Value
            .End = Cells(r, 8).Value + Cells(r, 3).Value
            .Subject = Cells(r, 4).Value
            .Location = Cells(r, 5).Value
            .Body = varBody
            .ReminderSet = Cells(r, 7).Value
            .BusyStatus = Cells(r, 9).Value
            .RequiredAttendees = Cells(r, 10).Value
            .Categories = "TestAppointment" ' add this to be able to delete the testappointments
            On Error GoTo 0
            .Save ' saves the new appointment to the default folder
        End With
        r = r + 1
    Wend
    Set olAppItem = Nothing
    Set olApp = Nothing
End Sub

Sub DeleteTestAppointments()
' deletes all testappointments in Outlook
Dim olApp As Outlook.Application
Dim OLF As Outlook.MAPIFolder
Dim r As Long, dCount As Long
    On Error Resume Next
    Set olApp = GetObject("", "Outlook.Application")
    On Error GoTo 0
    If olApp Is Nothing Then
        On Error Resume Next
        Set olApp = GetObject("Outlook.Application")
        On Error GoTo 0
        If olApp Is Nothing Then
            MsgBox "Outlook is not available!"
            Exit Sub
        End If
    End If
    Set OLF = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar)
    dCount = 0
    For r = OLF.Items.Count To 1 Step -1
        If TypeName(OLF.Items(r)) = "AppointmentItem" Then
            If InStr(1, OLF.Items(r).Categories, "TestAppointment", vbTextCompare) = 1 Then
                OLF.Items(r).Delete
                dCount = dCount + 1
            End If
        End If
    Next r
    Set olApp = Nothing
    Set OLF = Nothing
End Sub
I have attached my macro for your reference.


Thanks a lot for your help in advance.
Attached Files
File Type: zip Automatically Schedule Multiple Outlook Appointments.zip (20.1 KB, 270 views)

Last edited by abhay_547; 10-06-10 at 23:47.
Reply With Quote
  #2 (permalink)  
Old 10-09-10, 04:00
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Create Appointments in Outlook with Excel Macro.

Hi All,

Did anyone get the chance to look at the above post.

Thanks a lot for your help in advance.
Reply With Quote
  #3 (permalink)  
Old 10-11-10, 11:31
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Send Meeting requests through Outlook using excel macro.

Hi All,

Did anyone get the chance to look at the above post.

Thanks a lot for your help in advance.
Reply With Quote
  #4 (permalink)  
Old 10-17-10, 23:41
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Send Meeting requests through Outlook using excel macro.

Hi All,

Finally I got a code which uses dataobject method to copy the data from excel sheet to Oulook Meeting request body, It works great now but still the only thing which is not working as per my requirement is the data table (present in excel sheet) which doesn't get pasted with it's format. Is there any way to get the formatting to the same ?. Can we use the Rich Text format or Bitmap to paste only the data table ?. Please help..

Attached is my macro workbook for your reference.

Thanks a lot for your help in advance.
Attached Files
File Type: zip Sending Meeting Requests from Excel.zip (24.5 KB, 260 views)
Reply With Quote
  #5 (permalink)  
Old 10-18-10, 21:09
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Create Appointments in Outlook with Excel Macro.

Hi All,

Did anyone get the chance to look into the above post. ?

Thanks a lot for your help in advance.
Reply With Quote
  #6 (permalink)  
Old 10-31-10, 11:23
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Create Appointments in Outlook with Excel Macro.

Hi All,

Did anyone get the chance to look into the above post. ?

Thanks a lot for your help in advance.
Reply With Quote
  #7 (permalink)  
Old 05-18-11, 04:27
Amit009 Amit009 is offline
Registered User
 
Join Date: May 2011
Posts: 2
format the data on appointment email body copied from excel selection range

Hi,

I am new entrant on this forum. I am looking for "formatting the data on appointment email body copied from excel selection range". While browsing I found that even you had the same concern sometime back. Therefore can you please help me in providing a solution to this issue. Please note that I am not a in professional VB. I am learning and at very initail stage.

Thanks,
Amit
Reply With Quote
  #8 (permalink)  
Old 05-18-11, 22:40
abhay_547 abhay_547 is offline
Registered User
 
Join Date: Sep 2009
Posts: 78
Hi Amit,

Unfortunately, even I didn't get the solution for the same so far.

Regards,
Abhy
Reply With Quote
  #9 (permalink)  
Old 05-19-11, 03:39
Amit009 Amit009 is offline
Registered User
 
Join Date: May 2011
Posts: 2
Create Appointments in outlook with Excel Macro

Hi Abhay,

Thanks for your reply.

However can you please forward me the file, let me try if I can find some solution.

Regards,
Amit
Reply With Quote
  #10 (permalink)  
Old 02-24-12, 13:32
khoward@epic.com khoward@epic.com is offline
Registered User
 
Join Date: Feb 2012
Posts: 1
Sending Outlook meeting reqeusts from Excel

Abhay_547 - thank you so much for posting your Excel workbook with your macro for sending Outlook meeting requests - this is exactly what I'm looking for!

I tried to test this out and ran into an error: Run-time error '9': Subscript out of range. And then it highlighted this code:
Set Ws = Xl.Workbooks.Parent.Worksheets(Cells(r, 1).Offset(0, 5).Value)

Do you know what this means or how I can fix it? Thank you!


Quote:
Originally Posted by abhay_547 View Post
Hi All,

Finally I got a code which uses dataobject method to copy the data from excel sheet to Oulook Meeting request body, It works great now but still the only thing which is not working as per my requirement is the data table (present in excel sheet) which doesn't get pasted with it's format. Is there any way to get the formatting to the same ?. Can we use the Rich Text format or Bitmap to paste only the data table ?. Please help..

Attached is my macro workbook for your reference.

Thanks a lot for your help in advance.
Reply With Quote
Reply

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

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