track documents

U

upxtechie

Hello,
I am looking for a method to keep track of documents in MS Office by my
COM-add-in. When the user changes between documents the add-in must identify
the document which has received the focus, and recall where that document
originally was loaded from.

Everything would be quiet easy if there would be a saveAs event which whould
have access to the old name and the new name. Unfortunatelly there is no such
event available. Does anyone know a work-around to artificially create such a
save event ?

Live would be even more easy if the office applications would give each
document a unique ID at load time, and would hold such a ID during the whole
lifetime of the document in the application. I would no longer care about the
filename (and it's change by a saveAs operation), but would simply 'register'
the ID at the file load, and use it at documentChange events to identify the
document. Unfortunately I can't find such ID in the documents's properties.
Does anybody know about such a unique ID generated by MS Office applications ?
A work-around would be the storage of a unique ID in a
CustomDocumentProperty. It would work, unless a power user opens the document
properties and starts to do some 'clean-up' works. So that would not be a
save solution.
A invisible tag propertie at each document which could be used to store data
would be a way, but I did not find anything like that.

Some technical background about my project: The add-in shall work in Word,
Excel and Powerpoint in the versions Office 2000, XP and 2003. I am using VB6
+ Office Developer.

Best regards,
Joerg
 
W

Wei-Dong XU [MSFT]

Hi Joerg,

Thanks for posting at the newsgroup!

I have reviewed your thread. Currently I am finding somebody who could help
you on it. We will post back in the newsgroup as soon as possible.

If there is anything unclear, please feel free to post in the group and we
will follow up then.

Best Regards,
Wei-Dong XU
Microsoft Product Support Services

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/technicalsupport/supportoverview/40010469
Others: https://partner.microsoft.com/US/technicalsupport/supportoverview/

If you are outside the United States, please visit our International
Support page:
http://support.microsoft.com/default.aspx?scid=/international.aspx.
=====================================================
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang [MSFT]

Hi

Comments in line.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: track documents
thread-index: AcVD8B4LZzGPAqCDR4G62HJ3WI42AQ==
X-WBNR-Posting-Host: 212.202.101.210
From: =?Utf-8?B?dXB4dGVjaGll?= <[email protected]>
Subject: track documents
Date: Mon, 18 Apr 2005 01:25:02 -0700
Lines: 32
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.office.developer.com.add_ins
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.office.developer.com.add_ins:8277
X-Tomcat-NG: microsoft.public.office.developer.com.add_ins

Hello,
I am looking for a method to keep track of documents in MS Office by my
COM-add-in. When the user changes between documents the add-in must identify
the document which has received the focus, and recall where that document
originally was loaded from.

Everything would be quiet easy if there would be a saveAs event which whould
have access to the old name and the new name. Unfortunatelly there is no such
event available. Does anyone know a work-around to artificially create such a
save event ?
Since Word object modal did not expose the event handle, we have no way to
advise such a event.
Have you tried to use the BeforeSave event?
In the beforesave, we can temporary note the document, after saveas, the
document's name will be changed via the same document reference.
Live would be even more easy if the office applications would give each
document a unique ID at load time, and would hold such a ID during the whole
lifetime of the document in the application. I would no longer care about the
filename (and it's change by a saveAs operation), but would simply 'register'
the ID at the file load, and use it at documentChange events to identify the
document. Unfortunately I can't find such ID in the documents's properties.
Does anybody know about such a unique ID generated by MS Office applications ?
A work-around would be the storage of a unique ID in a
CustomDocumentProperty. It would work, unless a power user opens the document
properties and starts to do some 'clean-up' works. So that would not be a
save solution.
A invisible tag propertie at each document which could be used to store data
would be a way, but I did not find anything like that.

I think we may try to use the Document.Path to used as the ID.
string str =ThisDocument.Path + "\" + ThisDocument.Name
Because str is the fullpathname of certain document, in one machine, two
different document will not have same fullpathname.
 
U

upxtechie

Hello,
I don't think that your suggested solutions will solve the problem. At the
specific saveAs-scenario the add-in does not trigger the chain of events, but
is quiet passive in the background. Still it shall track what is going on.
The saveAs - scenario is as follows:
1. A document is loaded in the application. At this time my add-in knows
where the document was loaded from.
2. The user selects "file save as ..." from the menu
3. The event DocumentBeforeSave fires, and can be used by the add-in. But
the add-in gets to know only information about the document before the user
decides about path and filename. The add-in could suppress the "save as"
dialog - but that is not my intention.
4. The "save as" dialog is shown to the user. The user might cancel the
dialog, might keep path and filename or might change it. And he might make
his decissions within seconds, or might leave the dialog open during his
lunch break. So there is no point in using a timer function to check for
changes.
5. There is no event available which fires after the user has clicked the
okay-button. Therefore all preparations done with the DocumentBeforeSave
event are useless. Also there is no event for the case that the user clicked
"cancel".

I have already thought myself of using the document path and filename as a
unique ID. But this information is not permanent, as it can be changed by the
saveAs operation. That would not be a problem, if I would have a
procedure/event which has information about the filename "before saveAs" and
"after saveAs".

One approach could be the replacement of the Windows SaveAs dialog against
my own dialog. With the DocumentSaveAs dialog I could cancel the standard
SaveAsUI, and show my own dialog. That dialog would handle the user actions +
tracking of resources. But I am not realy a friend of this approach.

So all in all: I don't think that we have a solution for this scenario.
Somehow I have got the impression that the MS Office event modell has
forgotten some events. The available events might be okay for a script inside
a document, but not for a add-in. I would like to see events like
DocumentSave, DocumentSaveAs and DocumentClose. If you have any close contact
to the MS Office development team, please pass this on to them.

Best regards,
Joerg
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?dXB4dGVjaGll?=,

Been a while since I worked with this event, but...

Use DocumentBeforeSave, pick up the original path and filename, cancel the
automatic save, and DISPLAY (not Show) the FileSaveAs dialog box
(app.Dialogs(wdDialogFileSaveAs).Display). You can pick up from the Dialog
object
- whether the user cancelled or OKed
- what file path was stipulated

and take the action you prefer.
3. The event DocumentBeforeSave fires, and can be used by the add-in. But
the add-in gets to know only information about the document before the user
decides about path and filename. The add-in could suppress the "save as"
dialog - but that is not my intention.
4. The "save as" dialog is shown to the user. The user might cancel the
dialog, might keep path and filename or might change it. And he might make
his decissions within seconds, or might leave the dialog open during his
lunch break. So there is no point in using a timer function to check for
changes.
5. There is no event available which fires after the user has clicked the
okay-button. Therefore all preparations done with the DocumentBeforeSave
event are useless. Also there is no event for the case that the user clicked
"cancel".

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 :)
 
P

Peter Huang [MSFT]

Hi

Did Cindy's suggestion help you?
I have consulted the senior Office engineer and get the similar reply with
Cindy.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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