I have the following code to invoke Excel, where filename is the name of the form name.csv.
However, it won't work if Excel is already open. Is ther any way to get around this?
If Excel is already open, I=SHELLEXECUTEEX(SEI) just returns immediately without any waiting. Otherwise it works fine.
CALL ZEROMEMORY(LOC(SEI),SIZEOF(SEI))
SEI.CBSIZE = SIZEOF(SEI)
SEI.FMASK = SEE_MASK_NOCLOSEPROCESS
SEI.LPFILE = %LOC(FILENAME)
I=SHELLEXECUTEEX(SEI)
IF (I .EQ. 0) THEN
I = GETLASTERROR()
ELSE
CALL SYSOUT('0Waiting for Excel to finish...\(If Excel fails to start you may already have it open and need to close it.)')
I = WAITFORSINGLEOBJECT(SEI.HPROCESS, INFINITE)
I = CLOSEHANDLE(SEI.HPROCESS)
END IF