Results 1 to 5 of 5

Command Button + VBA Code to open Outlook calendar?

This is a discussion on Command Button + VBA Code to open Outlook calendar? within the Excel Questions forums, part of the Question Forums category; I'd like to create a command button within excel with VBA code linking it to a shared Outlook calendar. In ...

  1. #1
    Board Regular
    Join Date
    Apr 2009
    Posts
    381

    Default Command Button + VBA Code to open Outlook calendar?

    I'd like to create a command button within excel with VBA code linking it to a shared Outlook calendar. In theory, when you click on this button, it would open the shared calendar.

    Any ideas on if/how this can be accomplished?

  2. #2
    Board Regular
    Join Date
    Apr 2009
    Posts
    381

    Default Re: Command Button + VBA Code to open Outlook calendar?

    in the event it matters, the functional mailbox is called OpsAdmin.....or within active directory its F_OpsAdmin

  3. #3
    Board Regular JP2112's Avatar
    Join Date
    Oct 2008
    Location
    NYC
    Posts
    237

    Default Re: Command Button + VBA Code to open Outlook calendar?

    Code:
    Sub ShowSharedCalendar()
      Dim recip As Outlook.Recipient
      Dim calfolder As Outlook.MAPIFolder
      ' create shared recipient
      Set recip = session.CreateRecipient("OpsAdmin")
      ' reference to shared calendar
      Set calfolder = session.GetSharedDefaultFolder(recip, olFolderCalendar)
      calfolder.Display
    End Subp
    Regards,
    JP

    - Posting guidelines, forum rules and terms of use
    - Use [code][/code] tags when posting code
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes
    - My website: JP SoftTech

  4. #4
    Board Regular
    Join Date
    Apr 2009
    Posts
    381

    Default Re: Command Button + VBA Code to open Outlook calendar?

    I created the command button and pasted the code (althought i think subp should be sub at the end, right?)

    I did it exactly with what you have and the following way. Both flag a compile error: Expected End Sub

    Code:
    Private Sub CommandButton1_Click()
    Sub ShowSharedCalendar()
      Dim recip As Outlook.Recipient
      Dim calfolder As Outlook.MAPIFolder
      ' create shared recipient
      Set recip = Session.CreateRecipient("OpsAdmin")
      ' reference to shared calendar
      Set calfolder = Session.GetSharedDefaultFolder(recip, olFolderCalendar)
      calfolder.Display
    End Sub

  5. #5
    Board Regular JP2112's Avatar
    Join Date
    Oct 2008
    Location
    NYC
    Posts
    237

    Default Re: Command Button + VBA Code to open Outlook calendar?

    Yes, it should be "End Sub", no idea how that happened.

    Did you get the error BEFORE removing the "p"? That error will occur if there is a typo.
    Regards,
    JP

    - Posting guidelines, forum rules and terms of use
    - Use [code][/code] tags when posting code
    - Try searching for your answer first, see how
    - Read the FAQs
    - List of BB codes
    - My website: JP SoftTech

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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


DMCA.com