Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Disable word's save toolbar button and file menu button
Message
From
19/03/2001 20:48:44
 
 
To
16/03/2001 06:34:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00485474
Message ID:
00486714
Views:
26
Hi Cetin,

I read and was intrigued by your email. Thank you for all of your time!
You are correct. Just opening the document as read-only satisfies most of my requirements. You see, I allow the user access to a read-only, temporary copy of an actual document that I delete when the automation session is over. That is why I wanted the FILE|SAVE and SAVE toolbar button to be disabled when this temporary document is open. I did not want the user to feel as if he/she had the ability to modify the document. It is ok to "save as" a different file name but I don't what the original document altered in any way. So once again your suggestions work great. If the user does modify the temporary document in any way, WORD will prompt for a save but because it is open in read-only the save is actually a "save as" (with the appropriate "save as" file dialog). But, I am having one last problem. As you mentioned in your email, when you disable menu selections or toolbar buttons you are going to be prompted by WORD to save the changes to normal.dot. WORD prompts me if I want to make changes to normal.dot immediately after I hit the close button. That is the rub. I don't know how to close up a visible, active WORD after making changes to the toolbar buttons, etc, without storing those changes in normal.dot. I don't know how to close WORD without being prompted to save the changes to normal.dot.

Dr. G. (Neil)

>>Hi UTers'
>>
>>Is there a way to disable the SAVE button from the standard toolbar or the entire standard toolbar via automation? I also need to disable the FILE|SAVE menu selection from the system menu.
>>
>>You see, I don't want a user to save the modifications to a document he or she might have modified. I know that I could create a temporary copy of the document, allow the user to make changes to the copy, and at the end of the automation session simply delete the temporary file thereby not saving the changes. Yes, this will protect the original document from the user's changes but the user is receiving visual cues that he or she can save the document via the standard toolbar and the FILE|SAVE menu items. It is for that reason that I would prefer just to disable the saving options from the standard toolbar and FILE|MENU menu items.
>>
>>Thanx
>>DR. G. (Neil)
>
>Hi again Neil :)
>This is a duplication for you I know. Others might benefit.
>
>Neil,
>It's surprisingly fairly easy to do that but it's also easy to hurt yourself
>in addition.
>First code that disables Save from Menu and Toolbar :
>
>
>oWord = createobject("Word.Application")
>
>lcFile = getfile('DOC')
>if empty(lcfile)
> return
>endif
>with oWord
> .Documents.Open(lcFile)
> .Application.CommandBars("Standard").Controls("Save").Enabled = .F.
> .Application.CommandBars("File").Controls("Save").Enabled = .F.
> .visible = .t.
>endwith
>
>This doesn't prevent from 'Save Changes ?' dialog popup if modifications are
>made when user tries to exit word or close doc. Simple workaround is to open
>doc as readonly.
>However changes to Save button and menu bar option causes it to be saved to
>normal.dot and thus even if the user launches word at a later time
>independent from VFP s/he will still have those 2 disabled. IOW if you
>disable them via automation you're responsible to set them back to enabled
>(checking word's existence with a timer probably).
>
>Now for a moment think there is no problem in enabling-disabling them and
>you did that way. Still same doc could be opened independently from VFP and
>modifications saved or saved as. Right ? Normal prevention for that is to
>password protect the file. There is 2 passwords you can set for a file
>(open - modify). So I would recommend instead of disabling buttons :
>
>-Open the doc as ReadOnly
>-If you want to prevent modifications independent from VFP use
>'WritePasswordDocument' - modify
>-If you even want to prevent 'Save As' use 'PasswordDocument' - open
>(However this wouldn't prevent it from SaveAs once opened from VFP via
>automation - in that case you could disable-enable Save As and some
>additional things explained below)
>
>You could then open the doc as ReadOnly providing the password(s) from VFP
>via automation (See documents.Open() syntax).
>
>Now last challenger for paranoids:) is to disable any kind of save/saveas
>for the doc. I don't think you want to that also but as info :
>
>-You could create a VFPCOM.ComUtils object - say named oVFPCOM
>-Using oVFPCOM.BindEvents you could control DocumentBeforeSave event
>directly from VFP (However there is no guarantee that this would work with
>Word versions prior to word2000)
>
>Let's summarize :)
>The simpliest approach is to save template doc with a Modify password if
>also independent modification wouldn't be allowed (a clever user could
>SaveAs, delete original and rename new but it's a matter of respect - you
>can't prevent suicides:)
>
>All you would do is to open doc as readonly :
>
>oWord.Documents.Open(lcMydoc,,.T.) && Regarding to your post sounds this is
>all you need
>
>If you also have 'open' password set it in automation :
>
>oWord.Documents.Open(lcMydoc,,.T.,,lcOpenPassword)
>
>BTW readonly opening doesn't prevent modification in fact but prevents save
>(I assume this is related with your previous myDoc.doc pasting so you can
>still paste - and for that reason I didn't just say use a template).
>
>Hope writing long I didn't make it confusing and helps:)
>
>Cetin
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform