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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Read Only problem 2

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I am using Word in a vb application. I have a part assembled document that finally gets filled by the application. I made it so its a read only document, and its up to the user to save as. However if he saves as, an unwanted dialogue box appears "xxxx document should be opened as read only unless changes to it need to be changed.

Any ideas how:
1) I can protect the original document.
2) Allow an unhindered "save as" by the user.

Many thanks
 
This is a problem i am also experiencing.
The original document is vulnerable to being edited and saved by an unknowing user..
Did you find a solution to this?
 
I am not sure RonanK problem is the same as ZOR's. But let's see where to begin here.

1. To protect a Word document from wanton editing, use a password:
2. If a user can "Save As", they also can edit the document.

3. To go around annoying dialogs, have you considered letting users save the document only through your application?

The simplest solution: If your application fully controls access to the Word document (full automation), you will not have any of these problems.
 
Don't know about word, but in Excel automation there is a method you can call against the application (I think) object that basically stops all the annoying msgs...

mmilan.

 
I believe in word what mmilan is talking about is

objWordApp.DisplayAlerts = wdAlertsNone 'wdAlertsNone=0

give that a try.
 
Goo dto see this wake up. I have moved off this part of the program, still unresolved, but will return to it. My problem is I have a word document which looks like a form. Its protected to stop anyone changing it. My program fills in the bits. Trouble is if a user wants to save the completed word document he is presented with dialogue boxes saying something like the document should be opened in read only, do you want to save the changes made. I gave up to do something else for the time being. Maybe the display alerts bit that bjd4jc has posted might save the day, and I could control more from my program. I will return again when I try to solve my problems. Thanks RonanK for obviously doing a search and reviving this one.
 
Design, design, design.

I am assuming you are talking about a real executable VB app, not VBA. Correct?

Trouble is if a user wants to save the completed word document

I am not being rude, but this is silly. The key word is "if".

You have a Word document as a form. It is protected, presumably there are formfields (which require protection in order to work). However, even if there are NOT formfields, you have the document protected, because you do not want the user to edit the file. Correct?

You app fills in the bits.

1. is there ANY user input? You do not state so, but I assume there must be...other wise why even have the user looking at it?

2. The document is changed by something (the app), but WHAT is changed is not stated. In any case, from a design point of view, why would you even make changes to a document and NOT save it? In which case, the "if" is silly. Are there ever going to be cases where the app "fills in the bits" and you do not want to save it?

My point being, do not give the user an "if".

Are you creating the presenting file, the one the user sees, from a template, or are you opening an existing file, making changes, and doing a save as? This makes a difference to the way closing procedures can function.

Design, design, design.

You want to close a changed file? Explicitly close it (you do, not the user) with a read-only argument, if that is what you want it to be. The reason it is asking is that the file you are opening is read-only, and you are making changes to it.

A simple way around this is open the original file, open a blank file and copy the original file contents to the new file, and work from there.

This saves the original, as is.

Another way, is to create a new file from a template. Again, this saves the original, and any save operations are not going to have a read-only issue.

OR, you as the programmer explicitly close the file using SaveAs, with whatever arguments you need. If you have to (?) let the user have the "if", rewrite the SaveAs command into a form that you control, and again "if" they choose to save it, programatically close it, with the appropriate arguments.

Gerry
 
Many thanks Gerry.
Logical, Logical, Logical
Your posting made me re-think the situation.
The Word document actually is laid out to be a memo. The user does not fill in any information, that was previously got by earlier inputs from a form. I was trying to create everything programatically, but cheated in preparing the main memo page parts earlier in Word, so this bit I had to worry about someone deleting or amending. Deletion was to be always a worry, but amendments were first priority.

However I will now go back and create the whole Word document in code so no problems to copy/save as/protect etc etc.
I will do a save as dump for evey memo, avoiding all the "Do you want to save" dialogues, and its up to the user to save it if they want to. They could always retrieve the document dump and save as if they were quick enough before it was over written. So I think my lazyness has backfired on me. Have a star, I now see the horizon. Also thanks to Dimandja, never thought about passwording the document. A star. Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top