Identifying Word / Excel / PowerPoint documents

R

Roland Leisch

Hello!

I have quite a strange problem: I try to automate Word / Excel /
Powerpoint using Java and a Java-COM Bridge. The applicationes are
embedded into a OLE container. My problem is the following: There is now
way for me to identify an open document since there are problems with
naming:

I wrote an application which reads the contents of Documents,
Presentations and Workbooks collection and prints them out:

WORD:
-----

(the document in OLE container (actually the name of the document is
c:\test.doc)
Fullname ::: Dokument in com.jniwrapper.win32.automation.OleContainer
Name ::: Dokument in com.jniwrapper.win32.automation.OleContainer

(the new created document (manually))
Fullname ::: Dokument1
Name ::: Dokument1

(an existing document (opened manually))
Fullname ::: c:\reporting\Reporting.doc
Name ::: Reporting V2.doc

the same with POWERPOINT and EXCEL
----------------------------------

(an existing document (opened manually))
Fullname ::: C:\PATROL.ppt
Name ::: PATROL.ppt

(the new created document (manually))
Fullname ::: Präsentation2
Name ::: Präsentation2

(the document in OLE container (actually the name of the document is
c:\test.ppt)
Fullname ::: Präsentation incom.jniwrapper.win32.automation.OleContainer
Name ::: Testtitle

(an existing document (opened manually))
Fullname ::: C:\cat.xls
Name ::: catxls

(the document in OLE container (actually the name of the document is
c:\test.xls)
Fullname ::: Mappe4
Name ::: Mappe4



If I open more instances of my application containing an ole container
there are more documents with the same name and I cant find out the
filename of the opened files.

Can anyone help?
 
C

Cindy M -WordMVP-

Hi Roland,
I have quite a strange problem: I try to automate Word / Excel /
Powerpoint using Java and a Java-COM Bridge. The applicationes are
embedded into a OLE container. My problem is the following: There is now
way for me to identify an open document since there are problems with
naming:
If you don't need the specific name, just something with which to uniquely
identify the file in a container, perhaps you could try querying a
(builtin) DocumentProperty (part of the Office object model, but each
individual app exposes properties, as well). There's a Title property, for
example, that's usually populated - by default with text from the beginning
of the file. But it should also be possible to write the file name into a
built-in or custom property when the file is opened in the container, if
you need that information.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
R

Roland Leisch

Cindy said:
Hi Roland,



If you don't need the specific name, just something with which to uniquely
identify the file in a container, perhaps you could try querying a
(builtin) DocumentProperty (part of the Office object model, but each
individual app exposes properties, as well). There's a Title property, for
example, that's usually populated - by default with text from the beginning
of the file. But it should also be possible to write the file name into a
built-in or custom property when the file is opened in the container, if
you need that information.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


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

Hello Cindy!

Thanks for your answer: I also had the idea of adding custom properties,
but the problem ist that I want like to select the documents without
having to iterate the whole documents collection. Another thing is, that
I cant set the custom properties on document which have been opened
before my program started!

regards
Andreas
 
C

Cindy M -WordMVP-

Hi Roland,

Below...
Hello Cindy!

Thanks for your answer: I also had the idea of adding custom properties,
but the problem ist that I want like to select the documents without
having to iterate the whole documents collection. Another thing is, that
I cant set the custom properties on document which have been opened
before my program started!
I understood you to mean that you open documents in the containers, and after
you've opened more than one document / application you're no longer able to
identify which is which. Did I not understand the problem correctly? If I did
not, could you try explaining again EXACTLY what your problem is? I understand
that you're not able to pick up the entire file name after a file has been
opened. But I'd think your application should be equipped to store the full file
name as the file is opened into the container?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
R

Roland Leisch

I understood you to mean that you open documents in the containers, and after
you've opened more than one document / application you're no longer able to
identify which is which. Did I not understand the problem correctly? If I did
not, could you try explaining again EXACTLY what your problem is? I understand
that you're not able to pick up the entire file name after a file has been
opened. But I'd think your application should be equipped to store the full file
name as the file is opened into the container?

You understood the problem! The problem is that I need to activate a
certain socument and therefore I have to select it via Filename or index
(and index is changing while filename is not).

So my problem is that I cant select a file by filename since alle files
inside my ole container are namend "Dokument in olecontainer" (even if
their "real" filenames are totally different!).
 
C

Cindy M -WordMVP-

Hi Roland,
You understood the problem! The problem is that I need to activate a
certain socument and therefore I have to select it via Filename or index
(and index is changing while filename is not).

So my problem is that I cant select a file by filename since alle files
inside my ole container are namend "Dokument in olecontainer" (even if
their "real" filenames are totally different!).
But when your program opens any document in the container, at that point the filename
is known, correct?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
R

Roland Leisch

But when your program opens any document in the container, at that point the filename
is known, correct?

Correct. I have to use the filename as parameter to open the document in
an ole container. So my idea is to add a customproperty to the document
in which I save the document - name. But this doesnt work :-( (see my
posting "Strange behavior when setting custom property!" from 15.2.2005 )
 
C

Cindy M -WordMVP-

Hi Roland,
So my idea is to add a customproperty to the document
in which I save the document - name. But this doesnt work :-( (see my
posting "Strange behavior when setting custom property!" from 15.2.2005 )
Yes, this is the direction I was thinking in. And you've solved the problem
now, it seems?

Cindy Meister
 

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