When a user clicks ‘save’ button, I need to do some validation in macro, if it’s invalid, then cannot save the document. How can I prevent saving using a macro?
You can make own ‘save button’ and assign to the one the macro like this
Sub saveWithCondition
dim oDoc as object, a&
oDoc=ThisComponent
a=msgbox("Save?", 36)
if a=6 then 'condition
oDoc.store() 'save
end if
End Sub