WIN32OLE - problem with argv

R

Rainer

Hello,

I'm having a problem trying to pass parameters by reference with
WIN32OLE::ARGV. What I'm actually trying to do is getting access to
OneNote 2007 as described here...

http://msdn2.microsoft.com/de-de/library/ms788684(en-us).aspx

....but using Ruby instead.

Here's my little program:

-----
require "win32ole"
one = WIN32OLE.new("onenote.application")

class ON_CONST
end
WIN32OLE.const_load(one, ON_CONST)

a_string = ''

one.GetHierarchy(nil,ON_CONST::HsPages,a_string)
-----

GetHierarchy should pass the Hierarchy of OneNote pages into
"a_string" (I think). However, WIN32OLE::ARGV leaves "a_string" empty:

p WIN32OLE::ARGV
prompt> [-2147352572, 4, ""]

Using invoke won't make a difference:

one.invoke("GetHierarchy", nil,ON_CONST::HsPages,a_string)
p WIN32OLE::ARGV
prompt> [-2147352572, 4, ""]


Does anybody have an idea what I'm getting wrong? (I'm using Ruby
1.8.6)

Kind regards,

Rainer

P.S.: Any example for a successful pass by reference is appreciated,
even with another Office program like Excel or Word.

P.P.S.: I already have read the earlier discussion from Nov. 14 about
the same problem.
 
M

Masaki Suketa

Hello,
Here's my little program:

-----
require "win32ole"
one = WIN32OLE.new("onenote.application")

class ON_CONST
end
WIN32OLE.const_load(one, ON_CONST)

a_string = ''

one.GetHierarchy(nil,ON_CONST::HsPages,a_string)

I have not used OneNote 2007, so I'm not sure, but
could you try to use empty string (="") instead of nil as 1st argument?

one.GetHierarchy("",ON_CONST::HsPages,a_string)

Regards,
Masaki Suketa
 
M

Masaki Suketa

Masaki said:
one.GetHierarchy("",ON_CONST::HsPages,a_string)

Or try to use WIN32OLE#_invoke method.
include WIN32OLE::VARIANT
one._invoke(dispid, ["", ON_ONST::HsPages, a_string],
[VT_BSTR, VT_I4, VT_BSTR|VT_BYREF])
The dispid should be dispatch id of GetHierarchy method.

Regards,
Masaki Suketa
 
R

Rainer

Masaki said:
one.GetHierarchy("",ON_CONST::HsPages,a_string)

Or try to use WIN32OLE#_invoke method.
include WIN32OLE::VARIANT
one._invoke(dispid, ["", ON_ONST::HsPages, a_string],
[VT_BSTR, VT_I4, VT_BSTR|VT_BYREF])
The dispid should be dispatch id of GetHierarchy method.

Regards,
Masaki Suketa

Dear Masaki,

thank you very much, that did the trick! Now I'm getting a massive XML
string as promised!

Kind regards,

Rainer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top