Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Word Question

Status
Not open for further replies.

shannanl

IS-IT--Management
Apr 24, 2003
1,071
US
I need to review the contents of a Word document and generate a hash to ensure the document's contents do not change.

I have a function that will return a hash for a given string but I don't know how to read the contents of the Word Document.

How could I read the contents into a string?

Thanks,

Shannan
 
A starting point:
yourString = ActiveDocument.Range.Text

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Okay, the range.text seems to work but how can I check this when the user tries to save the Word document? Is there an event that is fired when the users saves a Word Document?

Thanks,

Shannan
 
Saving a document fires FileSave. But FileSave is a command within a document. An individual document can have its own FileSave. If it does not, then the FileSave in normal.dot is fired.

Gerry
My paintings and sculpture
 
I am trying to share a VBA program between documents. How can I have several word documents use the same code and what I want to do is have a master document so when I change code in the master it will trickle to all other documents.

Thanks,
Gaylene
 
Hi shannanl,

I can't see how having a hash value will
ensure the document's contents do not change
. All it can do is tell you whether the document has changed - and then only if you've stored the original has value. And herein lies a problem: storing the hash value changes the document. If you're only concerned with the text, you could get around this by storing the hash value in a custom DOCPROPERTY variable).

Perhaps you'd do just as well with a SAVEDATE field, since Word only updates this if the document has been changed before saving. If you use this in conjunction with a CREATEDATE field, and use File|Save As to save the document when it's 'finalised' you could compare the two dates: if theyre not the same the document has been changed.

You might also explore the possibilities with Word's password options (eg require a password to modify the document), but even this won't stop someone changing the document, printing it, then closing without saving - or simply copying the contents to another document.

Cheers

[MS MVP - Word]
 
I am trying to share a VBA program between documents. How can I have several word documents use the same code and what I want to do is have a master document so when I change code in the master it will trickle to all other documents.
Use a global template. Code in global templates are accessible to any document.

Gerry
My paintings and sculpture
 
If the contents of the Word must not change, you might consider making the content only accessible as PDF rather than Word document.
[idea]
With Acrobat security, you could then allow/disallow copying, printing, commenting etc.
Store your word docs in a separate environment inaccessible to "normal" users and publish the latest version to them in PDF form.

Would that be an option?

Cheerio,
Andy

[blue]Help us, join us, participate
IAHRA - International Alliance of Human Rights Advocates[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top