On Thu, 05 Jan 2012, [email protected] wrote:
> As a relative newcomer to Tkx on perl I have run into an issue with
> the Tkx::tk___chooseDirectory command. I use this in an application
> with its primary interface built using Tkx, that also spawns Excel
> using Win32::OLE.
>
> The Tkx::tk___chooseDirectory works fine before I have opened Excel.
>
> After I have opened Excel it just freezes. The application logic
> allows Excel to be closed when using Tkx::tk___chooseDirectory, and I
> have tried all methods to close excel and free unused library
> information, including using Win32::OLE Close/Exit/Quit commands,
> Win32::OLE->FreeUnusedLibraries(); , manually closing Excel, killing
> all Excel.Exe processes.

Try adding the following line at the top of your script, directly after
the "use Win32::OLE" line:

  BEGIN { Win32::OLE->Initialize( Win32::OLE::COINIT_OLEINITIALIZE() ) }

I suspect that chooseDirectory() makes uses of the Windows Common
Dialogs, and they only work correctly if the current thread uses the STA
(single threaded apartment) mode of OLE.

Cheers,
-Jan


Reply via email to