Results 1 to 3 of 3

Thread: general VBA question

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2
    Hi,

    I'm new to VB (although I did a lot of VB for Access 2 some years back), and I'm looking for info & examples on how to integrate VBA within a VB exe. For example, I'd like to automate inserting calendar dates into Outlook 2000 from within a VB application. Can anybody help narrow down my search for information ?

    Thanks

    David Mantripp
    The Fantastic Corporation R&D

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    Try this out. You'll probably have to fiddle around with it a little. This stuff is very picky. You need to add a reference to the Outlook 98 type library in your project.


    Public OlApp As Outlook.Application
    Public olNameSpace As NameSpace

    Private Sub Form_Load()

    Set OlApp = New Outlook.Application
    Set OlApp = CreateObject("Outlook.Application")
    Set olNameSpace = OlApp.GetNamespace("MAPI")
    olNameSpace.Logoff
    olNameSpace.Logon "login name", "password", False, True

    End Sub

    Private Sub AddAppointment()

    Dim olappt As Outlook.AppointmentItem

    Set olRecipient = olNameSpace.CreateRecipient("name")
    Set olappt = olNameSpace.GetSharedDefaultFolder(olRecipient, olFolderCalendar).Items.Add
    olappt.Location = "location"
    olappt.Subject = "Test Subject"
    olappt.Body = "Testing for calendar add. Did it work?"
    olappt.Start = CDate("12/31/00 01:00 AM")
    olappt.End = CDate("12/31/00 01:01 AM")
    olappt.Save
    Set olappt = Nothing

    End Sub

    Private Sub DeleteAppointment()

    Dim strFind As String
    Dim olappt As Outlook.AppointmentItem

    strFind = "[Start] = ""12/31/00 01:00 AM"" and [End] = ""12/31/00 01:01 AM"" and [Subject] = ""Test Subject"""
    Set olRecipient = olNameSpace.CreateRecipient("name")
    Set olappt = olNameSpace.GetSharedDefaultFolder(olRecipient, olFolderCalendar).Items.Find(strFind)
    olappt.Delete
    Set olappt = Nothing

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    olNameSpace.Logoff
    Set OlApp = Nothing
    Set olNameSpace = Nothing
    Set olRecipient = Nothing

    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    2
    That's really great - thanks for your time & help :-)

Posting Permissions

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



Click Here to Expand Forum to Full Width