PDA

View Full Version : Solved: Quick Access Toolbar Word 2007



jromano
05-29-2008, 08:51 AM
I am trying to prevent certain users from being able to do a "Save As". I have eliminated the option from the Office Menu. I have added Save As to the QAT, but have been unable to figure out how to either

A) make it invisible to certian users
B) disable and enable it through VBA


Anyone with any ideas, please let me know

Thanks

Jason

Zack Barresse
06-06-2008, 04:41 PM
Probably easier to disable it via VBA for certain users than manipulate the UI. There are always keyboard shortcuts too. ;)

What is the scope here Jason? If controlling the save event for a file you can use a standard module along with a class module (there is no direct event exposed to the ThisDocument in the OM, unfortunately).

In the VBE of your Word file:


Insert a Class Module
Rename your class module (I renamed mine as ThisApplication)
In your class module paste the code below marked as such
In a standard module (double click it) paste the code denoted below


In your ThisApplication class module (or whatever you named it):
Option Explicit

Public WithEvents oApp As Word.Application

Private Sub oApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
SaveAsUI = False
MsgBox "You wanted to save? Hmmmmm...????"
Cancel = True
End Sub

In your standard module:
Option Explicit

Dim oAppClass As New ThisApplication 'NOTE: This MUST match your class module name!

Public Sub AutoExec()
Set oAppClass.oApp = Word.Application
End Sub

Now you control the save events. Note you control ALL of the save events, so that Doc variable may become very important to you. You can also use the Environ("UserName") to get the current username of whoever is logged into the computer.

Please post back if you need more help.

Ken Puls
07-08-2008, 09:56 PM
Way late on this, but I fully agree with Zack.

Unless you use startFromScratch=true, you have no control over the QAT, so unless you're prepared to going the whole route, what Zack has proposed is the better way.

GregQik
07-12-2008, 02:49 AM
A simple way to control this is might be to hijack the 'SaveAs' command by writing your own 'SaveAs' command and provide some filtering in the code as to who may complete the 'Save As' task. NOTE: Might come unstruck if there is a keyboard shortcut for the task.

I believe this process is allowed by the word object model which will call VBA procedures of the same name in the following order:
* document procedure
* template procedure
* global template procedure
* normal.dot procedure

CreganTur
07-15-2008, 08:33 AM
Greg's correct.

You can 'hijack' an existing Word function, such as Save or SaveAs. When you do, you overwrite the default function. Here's an example:
Sub FileSave()
MsgBox "Saving changes to the document is not allowed." & vbCrLf & vbCrLf _
& "Please close the document when you are finished.", , "Action Canceled"
End Sub
Sub FileSaveAs()
MsgBox "Saving changes to the document is not allowed." & vbCrLf & vbCrLf _
& "Please close the document when you are finished.", , "Action Canceled"
End Sub

If a User tries to Save or use SaveAs they will get a message box (in my case), and that's all. This works for all methods of calling these functions- including menus, buttons, and hotkeys.