In VB I used the following statement to obtain the active Excel application object
Code: Select all
...
Set excel = GetObject(, "Excel.Application")
...
Code: Select all
...
Set excel = GetObject(, "Excel.Application")
...
Code: Select all
class predicates
getActiveObject : (comDomains::nativeClassId CLSID, pointer MustBeNull, iUnknown IUnknown [out]) -> hResult HResult language apicall.
clauses
run() :-
CLSID = memory::alloc_atomic(),
R1 = com_native::cLSIDFromProgID("Excel.Application", CLSID),
R2 = getActiveObject(CLSID, null, Native),
Disp = comDispInterface::new(uncheckedConvert(iDispatch, Native), comMemory::release),
writef("%\n%\n%\n%\n", R1, R2, Native, Disp).
Here is what I want to do in VBHowever the resulting "Disp" object is not as easy to use as in VB.
Code: Select all
...
set disp = getobject(,"Excel.applicaion")
'To display the name of the application, using the name property
msgbox disp.name
....
Code: Select all
...
CLSID = memory::alloc_atomic(),
com_native::cLSIDFromProgID("Excel.Application", CLSID)==0,
getActiveObject(CLSID, null, Native)==0,
Disp = comDispInterface::new(uncheckedConvert(iDispatch, Native), comMemory::release),
Disp:getProperty("Name")==comdomains::string(Name), %<---------- I get n exception on this line
vpiCommonDialogs::note(Name).
...
Code: Select all
class predicates
getActiveObject : (comDomains::nativeClassId CLSID, pointer MustBeNull, iUnknown IUnknown [out]) -> hResult HResult language apicall.
clauses
run() :-
CLSID = memory::alloc_atomic(),
comExceptionCheck::check2(com_native::cLSIDFromProgID("Excel.Application", CLSID)),
comExceptionCheck::check2(getActiveObject(CLSID, null, IUnk)),
if memory::isNull(IUnk) then
write("No active Excel application\n")
else
Unk = comInterface::new(IUnk, comMemory::release),
IDisp = uncheckedConvert(iDispatch, Unk:queryInterface(iDispatch::iid)),
Disp = comDispInterface::new(IDisp, comMemory::release),
comDomains::string(Name) == Disp:getProperty("Name"),
stdio::write(Name)
end if.
Code: Select all
CLSID = memory::alloc_atomic() ?
Code: Select all
memory::alloc_array(positive Count)
Code: Select all
CLSID = uncheckedConvert(comDomains::nativeClassId, memory::allocAllocateAtomic(sizeOfDomain(comDomains::nativeClassId))),
Code: Select all
CLSIDArray = uncheckedConvert(comDomains::nativeClassId,
memory::allocAllocateAtomic(Count * sizeOfDomain(comDomains::nativeClassId))),
Code: Select all
clauses
onFileNew(_Source, _MenuTag):-
CLSID = memory::allocAtomicHeap(sizeOfDomain(comDomains::nativeClassId)),
comExceptionCheck::check2(com_native::cLSIDFromProgID("Excel.Application", CLSID)),
comExceptionCheck::check2(getActiveObject(CLSID, null, IUnk)),
if memory::isNull(IUnk) then
stdio::write("No active Excel application\n")
else
Unk = comInterface::new(IUnk, comMemory::release),
IDisp = uncheckedConvert(iDispatch, Unk:queryInterface(iDispatch::iid)),
Disp = comDispInterface::new(IDisp, comMemory::release),
comDomains::string(Name) == Disp:getProperty("Name"),
stdio::write(Name)
end if
.