I have searched various newsgroups but cannot find an answer to this VBA problem.
The scenario:
You have a file open in Word which has the “Read-only recommended” option checked.
If you select the “Save” button in Word’s “native” (no macro) SaveAs dialog, a Word message appears saying “This file is read-only.” This message includes the full path of the file in parentheses. So far so
good.
HOWEVER, if you replace Word’s “File Save As” command with a macro (named FileSaveAs) then, if the user selects “Save” in the SaveAs Dialog, nothing happens. There does not seem to be a way to intercept
this “Save” button in this scenario. It’s only when “Cancel” is selected that error 5155 is generated.
Has anyone found a way round this? What I want is for the same message to appear saying that the file is read-only or the ability to display my own message saying much the same thing.
By the way, there is no problem if you change the name before selecting the “Save” button.
Here is a code sample (Also same behaviour with dlg.Show instead of dlg.Display):
Sub FileSaveAs()
Dim dlg As Dialog
Set dlg = Dialogs(wdDialogFileSaveAs)
‘Display the dialog box and exit if Cancel selected.
If dlg.Display = 0 Then ‘Cancel Button selected.
Set dlg = Nothing
Exit Sub
End If