PDA

View Full Version : Determine what text has been edited



nickirvine
07-15-2010, 02:38 AM
Hello All,

I hope you can help as you have been very helpful in the past.

What I'm trying to do is, have a word file that has loads of text already filled in, in perhaps text boxes (but within bookmarks would be better.) Then if anyone edits any text in any text box/bookmark a macro takes a note of which text box/bookmark has been edited.

They can make several changes to various different text box/bookmarks. The fields which have been edited display on the right hand side of the word file in a little list.

Then when they are done, the file is saved and an email is sent via outlook saying "The file xxx has been changed, the fields changes were xxx, the changes were xxx'

Any help on this will be really appreciated. I am using Outlook 2002 and Word 2002.

Thanks for your time.


Nick

nickirvine
07-15-2010, 07:51 AM
Please see attached an example of how i want file im trying to create to look.


Mod: sorry about duplicate posts, please delete all apart from this thread. Thanks.

fumei
07-15-2010, 11:58 AM
"Then if anyone edits any text in any text box/bookmark a macro takes a note of which text box/bookmark has been edited."

Stop right there.

The answer is: NO

At least not without a huge huge huge amount of coding/processing.

Think about it. Let's take one bookmark. Say the text in it is:

Yadda yadda yadda.

You go and change it to:

bladda bladda bladda.

Unless you have already gone and got the text "Yadda yadda yadda" and stored that into a variable AND added an additional string that states what bookmark it came from, Word has no way of knowing (or caring) that it is changed.

Let me be clear.

Bookmark name: "Whatever"
Bookmark text: "Yadda yadda yadda"

Make that into a DOCVARIABLE (and appending the name on the text).
ActiveDocument.Variables("Whatever").Value = _
ActiveDocument.Bookmarks("Whatever").Name & _
"_" & ActiveDocument.Bookmarks("Whatever").Range.Text
This gives "Whatever_Yadda yadda yadda". We can use this for the variable return - the identifier (bookmark name) and a value (bookmark range text).

Now you come along and test:
' get the current text of the bookmark
Dim CurrentText As String
Dim VarNameLength As Long
CurrentText = ActiveDocument.Bookmarks("Whatever").Range.Text
' need to get a length as various bookmarks have different name lengths
VarNameLength = Len(ActiveDocument.Bookmarks("Whatever").Name) + 1
' this gives us 9, the count of "Whatever_"
If CurrentText (" Bladda bladda bladda) <> ' does not equal
Right(ActiveDocument.Variables("Whatever").Value, _
Len(ActiveDocument.Variables("Whatever").Value)-VarNameLength)
' or "Yadda yadda yadda
Then
' they do not match

See? Can it be done, sort of. Yeah, sort of.

But tell me, what is the purpose of this? How you considered Track Changes (s much as I dislike Track Changes)? There are also Compare functionalities that may be considered.

geekgirlau
07-15-2010, 05:34 PM
I would suggest that you consider a proper document management system that allows you to save multiple versions of a document.

nickirvine
07-16-2010, 02:07 AM
Thanks for your help on this.

The purpose of this is long winded but I'll try to break it down it is basically that we hold a database of text and people need to request changes to this text. So that we can get it exactly right we want people to be able to edit what we hold currently to exactly how they want it.

I was thinking, would it be easier using excel maybe? then could be simpler,..."if cell A4 does not equal cell A5" that sort of thing.

fumei
07-16-2010, 11:20 AM
I am not following this.

Requesting a change - "people need to request changes to this text"
is absolutely NOT the same as people being able to make those changes - "we want people to be able to edit what we hold currently"

Generally speaking allowing anyone to edit/change things any way they want (which is what you are saying) is a BAD idea.

Asking for a change is perfectly reasonable.
Letting anyone do whatever they want (and again this IS what you are saying) is not, IMO, reasonable.