` Printed Icetips Article

Icetips Article



Windows API: Closing Excel from Clarion
2003-05-01 -- Ville Vahtera
 
> I use an OLE object to start Excel. When I call Quit Excel application
> disappears, but I still see it in process list.
> If I call the code several time it will start a new instance of Excel each
> time.

Try this example.

  PROGRAM
  MAP
     module('winapi$X¹Y…¡Ñcreate}='Excel.Application'
    ?Ole1{'woÜ›?ole1{'cells(1,1).value'}

  Accept
    Case Event()
    Of Event:CloseWindow
        !TitleString = 'Microsoft Excel - Book1'
        TitleString = 'Microsoft Excel'
        WindowHandle=FindWindow(0,Address(TitleString))
        If WindowHandle
          PostMessage(WindowHandle,WM_Close,0,0)
        Else
          Message('Application with text not found to be running > ' & TitleString )
        End
        Destroy(?Ole1)
    End

  END


HTH,
-Ville



Printed April 29, 2024, 8:18 pm
This article has been viewed/printed 35111 times.
Google search has resulted in 170 hits on this article since January 25, 2004.