can this be done in word?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a document that is a 'form', not in the word sense but in the paper
document sense.

The document contains a table of 8 columns and many rows

I would like to trap (whether through some word fields or document property
or vba) the date that the CONTENTS of that table, or the length of the table
(i.e. rows have been added or taken away), changes.

I don't want to just use the "save date" or the revision date (with change
tracking).

In excel I could do it by trapping the worksheet_change event and checking
if the changed range was in the "table" area.

Is there anyway to do it in word, or would I be better off to convert the
document into an excel document?

Thanks.
--

____________________________________________________________________________
________________
Please reply to newsgroup so everyone can benefit.
Email address is not valid (see sparkingwire.com)
____________________________________________________________________________
________________
 
Hi Mike

If you don't want to change tracking there's no easy way as there is with Excel.
It might be possible to do but compared to using Excel it would be a non trivial
task.

HTH + Cheers - Peter
 
Hi Peter,

I think I've figured out how to do what I want to do (perhaps my document is
much simpler than you're imagining - all it has is a header/footer & the
"content" which is the table, and I am using revision tracking, I'm not sure
why I said I wasn't maybe I was trying to say something else & mis-worded
it, oops.)

Before I go & try it though, I've got a question. As I mentioned above, I
AM using revision tracking, and I have (in the header of the document) a
word field to display the print date (i.e. {DATE \@ "M/D/YY"
\*MERGEFORMAT}). But because the revision tracking is on, everytime you
open the document, the date shows up revised on the printout, and if I to
find out the properties of the revision through vba code, the revision
doesn't seem to exist,even though the thisdocument.revisions.count is 1.

I did find out that if run the following code in the document_open event:

Dim myWindowState As WdWindowState
ThisDocument.Unprotect "pswd"
myWindowState = ThisDocument.ActiveWindow.WindowState
ThisDocument.PrintPreview
ThisDocument.ClosePrintPreview
ThisDocument.ActiveWindow.WindowState = myWindowState
ThisDocument.Protect Type:=wdAllowOnlyRevisions, Password:="pswd"

the date field is updated (seems a little silly in this case - is there a
flag to turn revision tracking off in fields, or in a particular field?)
correctly (as if I'd accepted the change) and loses the revision tracking
strikeout.

is my little event procedure going to affect any other revisions on the
sheet? Or better yet, is there a better way to let the field update itself
and not show up as a revision?


--

____________________________________________________________________________
________________
Please reply to newsgroup so everyone can benefit.
Email address is not valid (see sparkingwire.com)
____________________________________________________________________________
________________
 
Could you get by with a CreateDate field instead of Date? The field result
won't actually update, but it's possible that updating the field will still
show as a change.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Hi Mike

You need to modify your case as follows:

Dim myWindowState As WdWindowState

With ThisDocument
.Unprotect "pswd"
myWindowState = .ActiveWindow.WindowState

' Update most fields in the document but no tracked changes
.TrackRevisions = False
.PrintPreview
.ClosePrintPreview
.TrackRevisions = True

.ActiveWindow.WindowState = myWindowState
.Protect Type:=wdAllowOnlyRevisions, Password:="pswd"
End With

However, *why* are you using the ThisDocument object? The ThisDocument object
refers to the document/template the code is running in, which may not be the
ActiveDocument. If your code is in the template and you are creating a document
based on that template then your code is updating the template rather than the
document - which is what I would expect.

If you are using code in the document I have to ask why isn't it in the
template?

HTH + Cheers - Peter
 
Hi Peter,

regarding the .trackrevisions = false :
by turning off the document protection, doesn't that turn off the revision
tracking as well, if that was how revision tracking was turned on in the
first place?

As for why it's not a template but "thisdocument":
it's because the "form" is an ISO14001 EMS form, and we need to track the
revision of the format of the form, as well as the last revision of the
content, but because we only keep one list on the form, the content is saved
as the form, so we're not using templates for this particular "form". So
the code is attached to a document, not a template


One day when I have some time, I want to create a better way for us to
handle this (something like mailmerge or maybe putting some of our "forms"
into Access, but the person who created these documents was fairly basic in
their grasp of Word), but for now I'm just enjoying playing with VBA for the
sake of better learning something (I've got a decent grasp of the Excel
object model, so now I'm trying to get a handle on the Word OM, and figure
out what word can do) and trying to keep me from forgetting to update
things.


Thanks
 
Hi Mike

Yes ".TrackRevisions = False" does turn off revision tracking, that's why it's
turned on again using ".TrackRevisions = True".

Since you're using a document ActiveDocument is still more appropriate than
ThisDocument. You normally use ThisDocument in a template/add-in to
differentiate between the document and the template/add-in backing the document.
That's why I was confused when I saw it.

HTH + Cheers - Peter
 

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

Back
Top