Results 1 to 5 of 5
  1. #1
    avarusbrightfyre is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2009
    Posts
    60

    Add appointment to public calendar

    I have been searching for several days now for code that will add an appointment to a public calendar on our exchange network using vba code. Here is what I've found:

    Dim olApp As New Outlook.Application
    Dim olNameSpace As Outlook.NameSpace
    Dim olPublicFolder As Outlook.MAPIFolder
    Dim olAppt As Outlook.AppointmentItem
    Set olApp = CreateObject("Outlook.Application")
    Set olNameSpace = olApp.GetNamespace("MAPI")
    Set olPublicFolder = olNameSpace.Folders("Public Folders/All Public Folders/Sub-folder/Sub-folder/Sub-folder/Sub-folder/Actual Calendar File")
    Set olAppt = olApp.CreateItem(olAppointmentItem)
    With olAppt
    .Subject = "TEST SUBJECT"
    .Body = "TEST BODY"
    .LOCATION = "TEST LOCATION"
    .Move olPublicFolder
    End With ' olAppt
    olAppt.Save



    This appears to be close to working, but gives me an error message saying that it can't find the file. Debugging highlights the "Set olPublicFolder" line. Is there something wrong with the code, or maybe is there a better way to accomplish this? I'm in the military, so I've changed the folder path listed above for security reasons.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Probably need pathing, like:

    Drive designation:
    "C:\PublicFolders..."

    Or

    UNC (universal naming convention):
    "\\network server name here\PublicFolders..."
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    avarusbrightfyre is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Sep 2009
    Posts
    60
    That makes sense, but sticking the server name in front of my path doesn't seem to work. Is there some sort of special formatting or something that will point to the microsoft exchange server that the calendar is on?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Sorry, have no experience with MS Exchange. The pathing methods I suggested always work in my code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    hellothereu is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Posts
    1

    Outlook - Setting a reference to an Exchange Public Folder

    If you have a public folder or personal folder that you want to
    process in code then the following will show you how to do it. The key to this
    is finding out what the folders unique EntryID is. This unique id can be used to
    set a reference to a folder without having to go through loads of nested folders
    to get there.

    Paste the following VBA code into a new module.

    Private Sub GetOutlookFolderID()

    Dim olfolder As Outlook.MAPIFolder

    Dim olapp As Outlook.Application

    Set olapp = CreateObject("Outlook.Application")

    Set olfolder = olapp.GetNamespace("MAPI").PickFolder

    olfolder.Display

    Debug.Print olfolder.EntryID

    Set olfolder = Nothing

    Set olapp = Nothing

    End Sub



    Private Sub GetFolderFromID()

    Dim olfolder As Outlook.MAPIFolder

    Dim olapp As Outlook.Application

    Set olapp = CreateObject("Outlook.Application")

    Set olfolder = olapp.GetNamespace("Mapi").GetFolderFromID("Insert EntryIDHere")

    olfolder.Display

    Set olfolder = Nothing

    Set olapp = Nothing

    End Sub

    Run the GetOutlookFolderID sub which will
    open an outlook session and pop up a choose folder dialog box. Browse to the
    folder in question and double click it. This will then display that folder in a
    new window (check it's opened the correct one) and send the entry ID to the
    debug window.

    Go to the debug window and copy the
    extremely long EntryID string and replace the text in the second sub where it
    says InsertEntryIDHere with the text from the debug window.

    Run the second sub which should pop up the same window. Points to note. Some entryID's are changed when folders are moved about. This was taken from http://www.fabalou.com/Outlook/GetOutlookFolder.asp really helped me out when I went through this process

Please reply to this thread with any new information or opinions.

Similar Threads

  1. public variables
    By zul in forum Programming
    Replies: 3
    Last Post: 08-23-2011, 11:11 AM
  2. Appointment Calendar Scheduling
    By IdleJack in forum Access
    Replies: 4
    Last Post: 08-18-2011, 07:29 PM
  3. Appointment Booking Database
    By richie2837 in forum Access
    Replies: 1
    Last Post: 07-16-2011, 01:39 AM
  4. Replies: 4
    Last Post: 08-26-2010, 09:44 PM
  5. public instead of dim not working
    By DKY in forum Access
    Replies: 1
    Last Post: 10-14-2008, 11:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums