Protecting Bookmarks and word

D

Damien

Hi,

I have a macro driven word document that has a table with some values that
are bookmarked. When the document is finished the values in the bookmarks
are stored in a SQL database. This works great until it's given to the users.

The users have a tendency to delete random words, which is very annoying,
and end up deleting the bookmarks.

Is there any way of protecting these bookmarks? If they are deleted is
there a way to create them straight away? Or better still, it just deletes
the text and keeps the bookmark there.

Because the word document is in tables, I am unable to use section breaks to
protect the document.

Any ideas would be most welcome.

Thanks for you time

Damien
 
P

Peter Huang [MSFT]

Hi Damien,


Thanks for your posting!
Currently I am trying to find if there is any way for your scenario for
keep the bookmark position even if the characters marked by the bookmark is
deleted.

I will reply to you ASAP.

Thanks for your understanding!

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Peter Huang [MSFT]

Hi Damien,

When we are programming Word, we are programming with Word Object Modal.
After browsing through the Word VBA Object Modal document, there is no such
an approach to avoid an bookmark when delete the marked text by bookmark.
The Bookmark Object did not have event exposed which we can capture to do
further customization.

Also I just wonder if the text marked by bookmark is deleted, even if the
bookmark is there, what it referred to now?

Also what is the work document used to do?
Is it possible to protect the document and prevent it from editing? e.g.
Allow only Filling Forms, so that the End User will not delete the text.

If you have any concern, please feel free to let me know.

Best regards,

Perter Huang
Microsoft Online Partner Support

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

Jonathan West

Damien said:
Hi,

I have a macro driven word document that has a table with some values that
are bookmarked. When the document is finished the values in the bookmarks
are stored in a SQL database. This works great until it's given to the
users.

The users have a tendency to delete random words, which is very annoying,
and end up deleting the bookmarks.

Is there any way of protecting these bookmarks? If they are deleted is
there a way to create them straight away? Or better still, it just deletes
the text and keeps the bookmark there.

Because the word document is in tables, I am unable to use section breaks
to
protect the document.

Any ideas would be most welcome.

Hi Damien

Like Peter says, there is no means by which you can ensure that a bookmark
is not deleted when the user deletes its contents.

That last point - that the word document is in tables, is likely to be the
key to making the bookmarks a bit more persistent. If you select an entire
table cell when creating your bookmark, then even if the user deletes
everything in the cell, the bookmark is not deleted, because it includes the
end-of-cell marker.

Now, this might require you to make some small modification to the code that
puts the data into the SQL database, because the bookmark contents will now
include the end-of-cell marker, which you will now need to trim from the
string before inserting.

Another possible approach is to insert Form Fields into the document, and
then go to Tools, Protect Document, and select the "Forms" or "Filling in
Forms" option (it is named differently depending on which version of Word
you are using). Now, the user can only type text into the formfields. Your
code can extract the text from the formfields to insert it into the
database. Each formfield is an item in the Formfields collection in the Word
object model - from here it ought to be quite straightforward to adapt your
code. If you give your formfields the same names you formerly gave your
bookmarks, then the code changes should be trivial to achieve.
 

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