Closed Thread
Results 1 to 5 of 5

Copy a formatted table from excel sheet to outlook meeting request.

Hybrid View

  1. #1
    abhay_547
    Guest

    Copy a formatted table from excel sheet to outlook meeting request.

    Hi All,

    I have the below macro code which automatically sends the meeting requests from excel using outlook it works fine but I need to put some data as well on the meeting requests body when I am sending the meeting requests. my code copies the data as well on my meeting requests body but if my worksheet has a datatable with formatting then it just pastes the data with out any formatting. I am using dataobject method to copy the data to meeting body from excel sheet. I am using outlook 2003 so I can't use HTML method as Outlook 2003 doesn't support HTML for meeting requests. Below is my code :

    Sub Sendmeetingrequests ()
    ' 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 myPath As String
    
        Application.ScreenUpdating = False
        myPath = ActiveWorkbook.Path
    
        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
                .MeetingStatus = olMeeting
    
                ' read appointment values from the worksheet
                On Error Resume Next
                .Start = Cells(r, 1).Value + Cells(r, 2).Value
                .End = Cells(r, 1).Value + Cells(r, 3).Value
                .Subject = Cells(r, 4).Value
                .Location = Cells(r, 5).Value
                .ReminderSet = Cells(r, 8).Value
                .Importance = Right(Cells(r, 9).Value, 1)
                .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
    
            With olApp
                Dim Xl As Excel.Application
                Dim Ws As Excel.Worksheet
                Dim xlRn As Excel.Range
    
                Set Xl = GetObject(, "Excel.Application")
                Set Ws = Xl.Workbooks.Parent.Worksheets(Cells(r, 1).Offset(0, 5).Value)
                Set xlRn = Ws.Range("MailBodyText")
    
    
                Dim varBody As String
                Dim objdata As DataObject
                Dim DataObject As Object
                Set objdata = New DataObject
    
                Application.GoTo Reference:=xlRn
                Selection.Copy
                objdata.GetFromClipboard
                varBody = objdata.GetText
    
                With olAppItem
                    .Body = varBody '& vbCrLf & vbCrLf
                End With
            End With
    
            olAppItem.Close olSave
            r = r + 1
            Sheets("scheduleapp").Activate
        Wend
        Set olAppItem = Nothing
        Set olApp = Nothing
        Application.ScreenUpdating = True
    End Sub
    I have attached my macro file as well. Please have a look.

    Thanks a lot for your help in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Copy a formatted table from excel sheet to outlook meeting request.

    Your post does not comply with Rule 8 of our Forum RULES. Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser)to the cross-post. Expect cross-posts without a link to be closed a message will be posted by the moderator explaining why. We are here to help so help us help you!

    Read this to understand why we ask you to do this
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    abhay_547
    Guest

    Re: Copy a formatted table from excel sheet to outlook meeting request.

    Hi romperstomper,

    Thanks, I will ensure the same going forward.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,968

    Re: Copy a formatted table from excel sheet to outlook meeting request.

    Please add the links to your cross posts.

  5. #5
    abhay_547
    Guest

    Re: Copy a formatted table from excel sheet to outlook meeting request.

    Cross posted here: http://www.mrexcel.com/forum/showthread.php?t=506949

    Thanks a lot for your help in advance.

    Abhay

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1