Results 1 to 1 of 1

Thread: Macros for Excel and Outlook

  1. #1
    jpmorgenthal is offline Junior Member
    Join Date
    Sep 2005
    Posts
    2

    Default Solution: Macros for Excel and Outlook

    For those looking to import the exported CSV files into Outlook using a Macro, here's some code I put together to take the Export file formats and import them in.

    Sub AddMeetingEntries()
    Set myOlApp = CreateObject("Outlook.Application")

    For i = 2 To 10
    If Not Worksheets(1).Cells(i, 1).Value = "" Then
    Set myItem = myOlApp.CreateItem(1)
    myItem.Subject = Worksheets(1).Cells(i, 7).Value
    myItem.Location = Worksheets(1).Cells(i, 8)
    myItem.Body = Worksheets(1).Cells(i, 17).Value
    myItem.Start = Worksheets(1).Cells(i, 11).Value & " " & FormatDateTime(Worksheets(1).Cells(i, 12).Value - (4 / 24), vbShortTime)
    duration = (Worksheets(1).Cells(i, 9).Value / 24) + ((Worksheets(1).Cells(i, 10).Value / 60) / 24)
    myItem.End = CDbl(myItem.Start) + duration
    myItem.Save
    End If
    Next

    Set myItem = Nothing
    Set myOlApp = Nothing
    End Sub
    Sub AddCallEntries()
    Set myOlApp = CreateObject("Outlook.Application")

    For i = 2 To 10
    If Not Worksheets(1).Cells(i, 1).Value = "" Then
    Set myItem = myOlApp.CreateItem(1)
    myItem.Subject = Worksheets(1).Cells(i, 7).Value
    myItem.Body = Worksheets(1).Cells(i, 17).Value
    myItem.Start = Worksheets(1).Cells(i, 10).Value & " " & FormatDateTime(Worksheets(1).Cells(i, 11).Value - (4 / 24), vbShortTime)
    duration = (Worksheets(1).Cells(i, 8).Value / 24) + ((Worksheets(1).Cells(i, 9).Value / 60) / 24)
    myItem.End = CDbl(myItem.Start) + duration
    myItem.Save
    End If
    Next

    Set myItem = Nothing
    Set myOlApp = Nothing
    End Sub
    Last edited by jpmorgenthal; 2005-09-16 at 12:00 AM. Reason: Identify as a solution

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
  •