Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect to the running excel application instead of creating a new application instance #12

Open
lmaiaux opened this issue Feb 14, 2013 · 3 comments

Comments

@lmaiaux
Copy link

lmaiaux commented Feb 14, 2013

Hello All,

I am currently trying to connect to a running excel application with the following code

require 'win32ole'
@Excel = WIN32OLE.connect('Excel.Application')

... but this create a new EXCEL.EXE process instead of connecting to the existing one. (jruby 1.7.2 on windows XP 32 bits)

With MRI, WIN32OLE.new create a new process and WIN32OLE.connect tries to connect to a running one (and generates an error if it no excel application is running)

WIth JRuby-win32ole, I see in lib/win32ole/win32ole_ruby.rb that "connect" just calls "new". Is there a simple way to change it to get the connection feature or it is impossible because of the java implementation or another reason?
Is there any workaround to get this feature?

Thanks and Regards,
Lionel

@enebo
Copy link
Owner

enebo commented Feb 14, 2013

I think this may have just been an oversight on my part when this was originally implemented. Since jruby-win32ole uses C code ultimately, then connection should be possible, but it needs to be implemented. I don't know of a workaround offhand unfortunately.

@lmaiaux
Copy link
Author

lmaiaux commented Feb 15, 2013

Hello enebo,

Thanks for you reply.
Do you know if the jruby-win32ole project is still active and if there are some experts (like you?) who could have the time to implement it?
If it is not possible, could you give me few hints on how to start the job:

  • do you consider it is a hard/long job? what would be your evaluation?
  • does it require some expertize in windows and java development?
  • where are the C code to update? (I only see ruby and java code in the jruby-win32ole sources)
  • ...

Thanks and Regards,
Lionel

@enebo
Copy link
Owner

enebo commented Feb 15, 2013

I believe it will take some level of expertise in win32ole, JNI (using C), and Java. Possibly, you can find enough different examples of connection in variable win32ole examples on MSDN.

The C code to update is in a source package called racob: https://github.com/enebo/racob

It is not insurmountable but it will have some startup overhead since getting everything built and running is a little complicated (but I feel that way about Windows in general).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants