Search code examples
lotus

How do I instantiate Lotus 123 Application


I am opening Lotus files to get data from them. How do I instantiate the Lotus application without using GetObject? I have a reference to "Lotus 123". I am using Lotus SmartSuite 97.

This code works OK but it seeems I should be able to instantiate the Lotus application directly instead of using GetObject.

'get LotusWin
Dim LotusApp As Lotus123.Application
Dim wb As Lotus123.Document
Set wb = GetObject("C:\Temp\TestCopy.WK3", "Lotus123.Workbook")
Set LotusApp = wb.Application

LotusApp.Visible = True
wb.Activate

I tried to use Dim LotusApp As New Lotus123.Application but it give a compile error: Invalid use of New keyword.

I tried to use Dim LotusApp As New Lotus123 but it give a compile error: Expected user-defined type, not project.

I am using Excel VBA as my platform to run the code, but this is not an Excel question so please don't suggest adding an Excel tag.

Also I'm not interested in converting files to Excel.

How do I instantiate the Lotus application without using GetObject?


Solution

  • GetObject() returns a reference to an object provided by a COM component, in your case Lotus123.

    As you are communicating with Lotus123 via COM, and Lotus123 apparently does not support the "As New" syntax (which wasn't properly supported even in VB6, and Lotus123 is way older) I see no alternative to using GetObject().