Displaying InputBox on top of Calendar - Code worked fine with OUtlook 2007 but does not with Outlook 2010

Answered Displaying InputBox on top of Calendar - Code worked fine with OUtlook 2007 but does not with Outlook 2010

  • Tuesday, August 14, 2012 2:33 PM
     
     

    The following has been working fine with Outlook 2007.  It

      1. opens a Calendar and then

      2. an InputBox is displayed on top of the Calendar allowing the user to specify some information.

    With Outlook 2010, it ONLY works fine when using the "step by step mode"!  Otherwise it first displays the InputBox and the calendar only appears when the user has answered.  Would someone know a way to have this work?

      Sub Test2010()
         Dim objNameSpace As NameSpace
         Dim objCalendar As Folder
         Dim objView As CalendarView
         Dim VoitCalendrier As Outlook.Explorer
         Dim ObjPane As NavigationPane
       
         Set objNameSpace = Application.GetNamespace("MAPI")
         Call TrouveNomBAL(BALUtilisateur, BALPublique)
       
         Set objCalendar = objNameSpace.Folders(BALPublique).Folders("Tous les dossiers publics").Folders("LANG").Folders("BALs Partagées").Folders("Réservation")

        Set VoitCalendrier = objCalendar.GetExplorer
        VoitCalendrier.Activate
        VoitCalendrier.WindowState = olMaximized
       
        Set ObjPane = Application.ActiveExplorer.NavigationPane
        ObjPane.IsCollapsed = True
       
        Set objView = Application.ActiveExplorer.CurrentView
        With objView
          .DayWeekTimeScale = olTimeScale60Minutes
          .CalendarViewMode = olCalendarViewWeek
          .Save
        End With

        Info = InputBox("Quelle salle?", "3001")
      
    End Sub

    [Environment : Windows 7 64 bits /  Outlook 2010 32 bits / Also tested on Windows 7 32 bits / Outlook 2010 32 bits]

All Replies

  • Thursday, August 16, 2012 8:58 AM
    Moderator
     
     

    Hi Lise,

    Thank you for posting in the MSDN Forum.

    In your last thread, you've posted your code. However I cannot find anywhere the subroutine TrouveNomBAL() been defined, so the code snippet cannot get compiled on my machine.

    Besides, it will be helpful if you could change some variable's name into English to make it easier for me to understand your intention.

    I'm looking forward to your reply.

    Best regards,
    Quist


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us

  • Friday, September 21, 2012 12:28 PM
     
     

    Hi Quist,

    Just saw your post today... for reasons that would be to long to explain. Thank you very much!

    Here is an english version of a simplified code.  It  opens a calendar from my public folder on Exchange and it displays, on top of the calendar, an input box.  The answer given using the input box depends on what we see in the calendar.  As I said, this works fine with Outlook 2007.  Using Outlook 2010, it will also work fine but ONLY when run step-by-step. Otherwise it displays the input box first and then, once we have answered, the calendar is displayed.

    Sub ViewCalAndQuestion()   

       Dim objNameSpace As NameSpace
       Dim objCalendar As Folder
       Dim ViewCal As Outlook.Explorer
       Dim ObjPane As NavigationPane
       
       Set objNameSpace = Application.GetNamespace("MAPI")
       Set objCalendar = objNameSpace.Folders("Dossiers publics - lise.desjardins@umontreal.ca").Folders("Tous les dossiers publics").Folders("LANG").Folders("BALs Partagées").Folders("Reservation")
       Set ViewCal = objCalendar.GetExplorer
       ViewCal.Activate
       ViewCal.WindowState = olMaximized
       Set ObjPane = Application.ActiveExplorer.NavigationPane
       ObjPane.IsCollapsed = True
       AQuestion = InputBox("And the answer", "Answer here", 400, 400)
       
    End Sub

    If useful... the problem occurs with

      - Client : Outlook 2010
      - Server : Exchange 2003

    It works fine with

      - Client : Outlook 2007
      - Server : Exchange 2003

    Best regards,

    Lise


    Lise Desjardins Université de Montréal



  • Tuesday, October 30, 2012 2:03 PM
     
     Answered Has Code

    The solution is to do a short pause after displaying the calendar and before displaying the input box.  I have adapted the code found at http://office.microsoft.com/en-gb/outlook-help/HV080806488.aspx....

    Dim PauseTime, Start, Finish, TotalTime
    If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
        PauseTime = 5    ' Set duration.
        Start = Timer    ' Set start time.
        Do While Timer < Start + PauseTime
            DoEvents    ' Yield to other processes.
        Loop
        Finish = Timer    ' Set end time.
        TotalTime = Finish - Start    ' Calculate total time.
        MsgBox "Paused for " & TotalTime & " seconds"
    Else
        End
    End If

    Lise Desjardins


    Lise Desjardins Université de Montréal