On Mon, Dec 24, 2012 at 8:37 PM, Dami=E1n M. Gonz=E1lez <lists / ruby-forum.c=
om>wrote:

> Hi guys, been researching about pop up the "open" file dialog of
> Windows. I didn't find nothing, just a snippet of code that doesn't
> work:


Short answer: see http://www.ruby-forum.com/topic/168114

Long answer:
It would have been helpful to include the error message and the Windows and
Ruby software versions you are using. See
http://www.catb.org/esr/faqs/smart-questions.html#beprecise

Trying your example on Windows 7 Ruby 1.9.3 I get
Win32_Test.rb:3:in `initialize': unknown OLE server:
`MSComDlg.CommonDialog' (WIN32OLERuntimeError)

This suggests that component is not installed on my machine. Even if it was
installed, Google suggests there would be a Microsoft component licensing
issue:
http://dutchgemini.wordpress.com/2010/12/23/vba-cannot-create-mscomdlg-comm=
ondialog-activex/


If you insist on solving your problem by using native Windows dialogs, an
alternative to an OLE component would be to access the Win32 API directly:
http://www.ruby-doc.org/docs/ProgrammingRuby/html/win32.html#S3

See Win32 GetOpenFileName():
http://msdn.microsoft.com/en-us/library/ms646927%28VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms646829(v=3Dvs.85).aspx#open_file

GetOpenFileName() is deprecated but is probably easier to use than the
alternative. However, it will involve packing the OPENFILENAME members, as
in the example I linked to at the start of my email.

Feliz Navidad,
Kieran
--=20
Kieran Tully, Software Developer and Tenor, http://ktully.net