SaveAsUI doesn'T work in MS Word

  • Thread starter online.experiment
  • Start date
O

online.experiment

Dear Group,

I am a newbie in vba and tried to google a solution but couldnt
find....

I want to prevent the user to save (or ask if he really wants to
save).

The code works fine in Excel (VBAProject - ThisWorkbook), but not in
Word (Project - Microsoft Word Objects - ThisDocument) - see below...

How do I have to change the vba word code?

Thanks a lot,

Andreas

EXCEL: works!
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True

End Sub

WORD: doesn't work
Private Sub Document_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True

End Sub
 
O

online.experiment

Hi found the solution!!!

Just added a module which is executed in the beginning.

Dim X As New EventClassModule
Sub AutoExec()
Set X.appWord = Word.Application
End Sub

Thanks Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top