Problem:
The COBOL code attached just does what's pasted below which is a VB code
OL2000: How to Programmatically Change the Displayed Calendar Date
http://support.microsoft.com/kb/259767
some more glue regards to
Outlook Object Model Overview
http://msdn2.microsoft.com/en-us/library/ms268893(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/aa221870(office.11).aspx
VB sample:
Dim ol As Object
Dim olns As Object
Dim oCalendar As Object
Dim oAppt As Object
Dim oViewCmdBar As Object
Dim oItem As Object
Dim nItem As Integer
Sub ChangeCalendarView()
' Create Outlook Application object.
Set ol = CreateObject("Outlook.Application")
Set olns = ol.GetNameSpace("MAPI")
' Retrieve the Calendar folder.
Set oCalendar = olns.GetDefaultFolder(olFolderCalendar)
' You can retrieve your specific appointment differently.
' This is just to get the first item, so we can see the calendar
' displayed for that day.
Set oAppt = oCalendar.Items(1)
' Retrieve the View menu.
Set oViewCmdBar = oAppt.GetInspector.CommandBars.Item("View")
' Locate "Calendar..." on the View menu.
nMenuItem = 1
Set oMenuItem = oViewCmdBar.Controls(nMenuItem)
Do While Not oMenuItem.Caption = "Ca&lendar..."
nMenuItem = nMenuItem 1
Set oMenuItem = oViewCmdBar.Controls(nMenuItem)
Loop
' Display the appointment. This must be done in order for the
' calendar to be displayed on the next statement.
oAppt.GetInspector.Display
' Execute the Calendar command on the View menu.
' This is the command that displays the calendar.
oMenuItem.Execute
End Sub
Resolution:
COBOL code attached:
$set ooctrl( P) mfoo
Identification Division.
Program-ID. MailDemo.
Environment Division.
Class-Control.
entrycallback is class "entrycll"
exceptMgr is class "exptnmgr"
oleExceptMgr is class "oleexpt"
olesup is class "olesup"
ClassOutlook is class "$OLE$Outlook.Application"
.
Working-Storage Section.
copy "mfole.cpy".
01 osException object reference.
01 aClassHandle object reference.
78 CRLF value x"0D0A".
copy "MSOutlook11.0.cpy".
01 objOutlook object reference.
01 olns object reference.
01 FolderCalendar OlDefaultFolders.
01 oCalendar object reference.
01 oAppt object reference.
01 ObjWrk1 object reference.
01 ObjWrk2 object reference.
01 oViewCmdBar object reference.
01 nMenuItem int value 1.
01 StrToSearch pic x(50) value z"Ca&lendar...".
01 Caption pic x(50).
01 oMenuItem object reference.
local-storage section.
linkage section.
01 lnkErrorNumber pic x(4) comp-5.
01 lnkErrorObject object reference.
01 lnkErrorText object reference.
Procedure Division.
main-control section.
*> Set up the exception handling
invoke entrycallback "new"
using z"onOleException"
returning osException
invoke exceptmgr "register"
using oleExceptMgr
osException
*> Create the Outlook session.
invoke ClassOutlook "new"
returning objOutlook
invoke olesup "setDispatchType" using by value 0
invoke objOutlook "GetNameSpace" using by reference z"MAPI"
returning olns
*> OL2000: How to Programmatically Change the Displayed Calendar Date
*> http://support.microsoft.com/kb/259767
set olFolderCalendar of FolderCalendar to true
invoke olesup "setDispatchType" using by value 0
invoke olns "GetDefaultFolder" using by value FolderCalendar
returning oCalendar
invoke oCalendar "Items" using by value 1
returning oAppt
invoke olesup "setDispatchType" using by value 0
invoke oAppt "GetInspector" returning ObjWrk1
invoke ObjWrk1 "CommandBars" returning ObjWrk2
invoke ObjWrk2 "getItem" using by reference z"View"
returning oViewCmdBar
perform varying nMenuItem from 1 by 1
until Caption = StrToSearch
invoke oViewCmdBar "getControls"
using by value nMenuItem
returning oMenuItem
invoke oMenuItem "getCaption" returning Caption
display "*--> " nMenuItem " >> " Caption
end-perform
invoke ObjWrk1 "Display"
invoke oMenuItem "Execute"
*> ...
stop run.
*==========================================================
callback section.
entry "onOleException" using by reference lnkErrorObject
by reference lnkErrorNumber
by reference lnkErrorText.
display "An OLE error has been returned!"
display "The error number was: " lnkErrorNumber
if lnkErrorText not = null
display "The error description is: "
invoke lnkErrorText "display"
display " "
end-if
stop run
exit program.