Board index » delphi » Problem with Word SaveAs dialog not prompting for overwrite

Problem with Word SaveAs dialog not prompting for overwrite


2006-09-20 09:06:21 AM
delphi274
I'm writing an application that needs to determine when a Word document
created/loaded by automation is saved. To this end I have added an event
handler for the DocumentBeforeSave and added my own save logic so I can then
do the processing I need to do.
The issue is with the SaveAs dialog and when a user goes to overwrite an
existing file. Typically Word will display a confirmation dialog, however in
this situation nothing is happening at all. Reading on the Web made me aware
of the DisplayAlerts property, but changing this has no affect on the
dialogs behaviour.
Any help in getting the correct behaviour out of the SaveAs dialog would be
appreciated.
Some psuedo code of what I have been doing is as follows:
if SaveAsUI = true then
Doc.Application.Dialogs.Item(wdDialogFileSaveAs).Show
else
Doc.Save
endif
if Saved then
//Do what I need to do on save
endif
 
 

Re:Problem with Word SaveAs dialog not prompting for overwrite

Aaron:
I don't know if this helps, but I just impose my own test and dialog when
SaveAs is needed. Something like this:
targetfile := 'sample.rtf'; (or some other name from a previous dialog?)
if fileexists(targetfile) then
begin
confirm := MessageDlg(targetfile + ' already exists.' + #13#10#13#10 +
'Click OK to overwrite this file.',mtWarning, mbOKCancel, 0);
if confirm = mrCancel then ... (give option to choose new name or
something else?);
end;
Word.SaveAs
(targetfile,wdFormatRTF,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyPa
ram,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,Empty
Param,EmptyParam,EmptyParam);
SB