Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Call to Excel fails when Excel already open

$
0
0

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


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>