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

Add in a dialog confirmation box to Save button in Office 1

Status
Not open for further replies.

JMB70

Programmer
Mar 20, 2002
10
GB
Hi, I have a document management system that is the desired location for saving documents. The intention is that I will move the Save button to a less prominent location than the new applications save button. I would like a dialogue box to appear whenever the standard Save button is used that will check that the user really wants to save their document outside of the document management system.

Is this possible to do? Or do I need to rewrite the functionality of the Save button completely?
 
I would really appreciate any help on this issue, is there any obvious FAQs that I should be reading? Or a protocol to asking questions?
 
Don't be so impatient...
Nobody here is paid for replying and Tek-Tips is not an help desk.
If you haven't got an answer yet, it's just because the issue isn't obvious.


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry didn't mean to come across as impatient, just didn't want my request for help to dissapear because I'd misunderstood some form of protocol.

I certainly wasn't demanding an answer, and do realise that this is free advice I'm seeking.

Thanks for the FAQs.
 
Hi JMB70,

You say "Office" in the title. Each Application is different, I'm afraid.

It'sIn a standard code module in Word for example, you can do this ..

Code:
[blue]Sub FileSaveAs()
    If MsgBox("Are you sure?", vbYesNo) = vbYes Then _
        Application.Dialogs(wdDialogFileSaveAs).Show
End Sub[/blue]

which will intercept the SaveAs command and only allow it to go ahead after confirmation.

If you could be a bit more specific with your problem, an appropriate solution can be found.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Thanks Tony,

Do I need to create a new button and put this code behind it? Or can I edit the standard MS buttons code?

I do need to do it for the whole of office, but if it is a case of having to do each app seperately then I'll do that.

I'm trying to make sure people don't just automatically save their document locally as it needs to go into a document management system for auditing purposes. Obviously we still need the ability to save locally in case of network failure or other reasons, but I want the dialog to make the user think about whether they're doing the right thing.

We already have the document management system button in place, so it's just the altering of the MS Save button that I'm trying to achieve.

Does that make more sense?

Thanks ever so much for your help.
 
Hi JMB70,

The solution I posted for Word just intercepts the SaveAs command, however it is invoked. There is full info on this on the MS website but I haven't got the address to hand.

It is by far the easiest in Word - I'll come back with more info on the other apps (and that link) later - if no-one else does so first.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Thanks Tony, you're a star, that has worked a treat for the SaveAs option.

I want to do the same for the standard Save option, is there a page you know of where I can find the names of all the functions to call...

You have written: Application.Dialogs(wdDialogFileSaveAs).Show

to call the SaveAs option, but as there isn't a dialog box for standard Save I don't really know what the call is.

As you can tell, I'm very new to this!
 
It's o.k.

I've worked it out. thisdocument.save
 
Hi JMB70,

Other apps ...

In Excel there is a BeforeSave Workbook Event you could trap, but it would need to be coded in every workbook - there is an Application version of the same event which you could use. I guess there are similar events in other apps but I don't know the details without a bit of checking up.

An alternative method is the one outlined in the M$ article, which should work in all apps. Here is a bit of code which will find all menu and button Save Commands and route them to your own routine ..

Code:
[blue]Sub SetUpIntercept()
    
    Dim cb As CommandBar
    Dim cbc As CommandBarControl
  
    On Error Resume Next

    For Each cb In Application.CommandBars
        Set cbc = cb.FindControl(Id:=3, Recursive:=True)
        If Not cbc Is Nothing Then cbc.OnAction = "mySave"
    Next

End Sub


Sub mySave()
    If MsgBox("Are you sure?", vbYesNo) = vbYes Then _
        ActiveWorkbook.Save
End Sub[/blue]

Note the Id for Save is 3 (as coded); the Id for SaveAs is 748. You'll need to fine-tune it and show the Dialog for SaveAs, etc. A final point is that this will not trap the User pressing keyboard shortcuts (<Ctrl><s> for Save)

You can trap this in Excel by using ..

Code:
[blue]Application.Onkey "^s", "mySave"[/blue]

Across multiple Applications there are going to be some differences but I hope this points in the right direction.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top