Open Word Document in Word 2007

M

Marion

I have an Oracle application that displays a word document from the Help
button. My code works fine with Word 2003 but in Word 2007, the Word
application is activated but the document is not displayed.

Here is the code that works with Word 2003 but not Word 2007. In Word 2003
the Open works with the argument list but I was hoping to define the
parameters and invoke the Open without the argument list.

procedure fileopen (fname in varchar2) is
arglist ole2.list_type;
obj_hnd OLE2.OBJ_TYPE;
docs_obj OLE2.OBJ_TYPE;
begin
obj_hnd := ole2.create_obj('Word.Application');
OLE2.SET_PROPERTY(obj_hnd, 'visible', 1);
docs_obj := ole2.get_obj_property(obj_hnd, 'Documents');
OLE2.SET_PROPERTY(docs_obj, 'FileName', fname);
OLE2.SET_PROPERTY(docs_obj, 'ReadOnly', 'True');
OLE2.SET_PROPERTY(docs_obj, 'Visible', 'True');
OLE2.SET_PROPERTY(docs_obj, 'Format', 'wdOpenFormatAllWord');
ole2.invoke(docs_obj, 'Open'); -- open document in read_only mode
arglist := ole2.create_arglist;
ole2.add_arg (arglist, fname);
ole2.add_arg(arglist, 1);
ole2.add_arg(arglist, 1);
ole2.add_arg(arglist, 1);
ole2.invoke(docs_obj, 'Open', arglist); -- open document in read_only mode
ole2.destroy_arglist(arglist);
end;
Any ideas would be appreciated
 
C

Cindy M.

Hi Marion,
Here is the code that works with Word 2003 but not Word 2007. In Word 2003
the Open works with the argument list but I was hoping to define the
parameters and invoke the Open without the argument list.

I no nothing about the programming language you're using, and it's not at all
clear what code actually has worked before in 2003 and what is new in the
snippet you're showing, however...

There's no way to "set properties" against the Documents object that will
then be considered when using the Open method. There's no way to specify the
parameters for the method in any way other than passing them as part of the
method.

So I believe you do have to use the argument list if you're using Invoke.

I suggest you test using the same code in 2007 as you used in 2003. As far as
I know, it should be completely backwards compatible...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
M

Marion

I discovered that the code is not the problem. The code works in both Word
2007 and Word 2003. There was a bugfix in 1995 that added a \ to the end of
the document passed in to the fileopen procedure. When I removed the \ the
document opened in Word 2007. This also works with Word 2003. I'm not sure
why Word 2003 works with or without the \ but Word 2007 does not work with
the \.
 

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

Top