Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 04-27-2012, 02:07 AM
macropod's Avatar
macropod macropod is offline Prompt when close the document Windows 7 64bit Prompt when close the document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,341
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi umesh,

Using Events requires that you instantiate the app object class. To do this, create a new class module in your document or, preferably, its template, to register your events. At the top of the module put:
Code:
Public WithEvents wdApp As Word.Application
Public WithEvents wdDoc As Word.Document
Below that, add code like the following to intercept the save event:
Code:
Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim Rslt As Variant
Rslt = MsgBox("Have you done your homework?", vbYesNo)
If Rslt = vbNo Then Cancel = True
End Sub
Then, in a normal code module, put:
Code:
Dim wdAppClass As New ThisApplication
Public Sub AutoExec()
Set wdAppClass.wdApp = Word.Application
End Sub
This will allow you to get events from your Word document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Prompt when close the document Help with Document Properties Prompt Macro KJJ Word VBA 14 11-10-2016 08:18 PM
Prompt when close the document Suppress the Save prompt UTSUPPORT Word 1 01-16-2012 09:27 PM
Prompt when close the document Date Range Prompt MikeWooZ Excel 6 12-04-2011 02:10 PM
Prompt when close the document Prompt for Selection Point in document caddcop Word VBA 3 06-14-2011 05:45 PM
Disable email security prompt mcinnes01 Outlook 1 03-17-2011 07:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:55 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft