xsharp.eu • Hi Guys Problems compiling outlook code in X# Can anyone help please
Page 1 of 1

Hi Guys Problems compiling outlook code in X# Can anyone help please

Posted: Mon Apr 08, 2019 3:00 pm
by rn@warner-it.com
Hi Guys and Chris,
Sorry to bother you again but I am afraid I cannot get the code to compile properly in X# there seems to always be an error regardless which variant I try this simple code also wont work. Yesterday I sent you something similar for the contacts to show the contacts in outlook I cannot get it to compile error free. Some of the code that I had for Vulcan use to work but it does not in X# because of compile errors. Can you please help. Is it possible to ask your colleagues if they are also encountering the same problems. There must be a possibility of a general fix. Code that used to work Vulcan 32 bit just has compile errors in X#.

Thanks
Raymond
FUNCTION Calendar() AS VOID

/* Original Code VB.Net Chris Cannot compile it error free in X#
Dim myNamespace As Outlook.NameSpace

Set myNamespace = Application.GetNamespace("MAPI")

Set Application.ActiveExplorer.CurrentFolder = _

myNamespace.GetDefaultFolder(olFolderCalendar)
*/

LOCAL _myNamespace AS Microsoft.Office.Interop.Outlook.NameSpace //Outlook.NameSpace
LOCAL outApplication AS Microsoft.Office.Interop.Outlook.Application

_myNamespace := outApplication.GetNamespace("MAPI")


outApplication.ActiveExplorer.CurrentFolder := _myNamespace.GetDefaultFolder.olFolderCalendar //(olFolderCalendar)

RETURN
error XS0119: 'Microsoft.Office.Interop.Outlook._Application.ActiveExplorer()' is a method, which is not valid in the given context 370,5 Ray_Outlook.prg FormApp6
error XS0119: 'Microsoft.Office.Interop.Outlook._NameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders)' is a method, which is not valid in the given context 370,5 Ray_Outlook.prg FormApp6

Hi Guys Problems compiling outlook code in X# Can anyone help please

Posted: Mon Apr 08, 2019 3:18 pm
by Chris
Hi Raymond,

I think the differences are due to different versions of the office dlls, you are probably using a different version than what the sample is using. The error message says that "ActiveExplorer" is a method, in which case you need to use "()" to call it, so try changing your code to:

outApplication:ActiveExplorer():CurrentFolder := .....

does it work this way?

Btw, please do not create new threads for the same topic, better just reply to the ones you have already started, it's easier to manage everything this way.