Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2012, 11:51 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default Prompt when close the document

Hi how can I make word document to pop up a window (once I try to close the document) - stating

"please ensure you have checked the following ----

(any text of my choice)"





Regards

Umesh Banga
Reply With Quote
  #2  
Old 04-24-2012, 04:42 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: 21,962
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

Yes, but it's not a trivial process. See: http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-24-2012, 11:14 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default

so writing the code given on this page will allow for prompt screen to pop up.

if not do you know anywhere I can get the code or any open source program or add in for this functionality.
Reply With Quote
  #4  
Old 04-24-2012, 11:47 PM
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: 21,962
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,

No, the code in that link is just to show you what's involved. You also need to understand that if the user has their macro security set too high, or if they choose to disable the macro when the document opens, there will be no prompt.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #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: 21,962
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
  #6  
Old 04-27-2012, 09:35 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default Macro for prompting the event in word

Hi Paul,

Please see the attached document, it gives some error message.

Regards

Umesh
Attached Files
File Type: docx PromptEventMacro.docx (10.1 KB, 12 views)
Reply With Quote
  #7  
Old 04-27-2012, 10:55 PM
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: 21,962
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,

There's no code in your document - it's a docx file. Either save the file in doc format or save it as docm then zip it before attaching it to a post.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-28-2012, 07:50 AM
Charles Kenyon Charles Kenyon is offline Prompt when close the document Windows Vista Prompt when close the document Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,124
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by ubns View Post
Hi Paul,

Please see the attached document, it gives some error message.

Regards

Umesh
To expand on what macropod said, macros are stored in normal.dotm by default. You have to actively try to store them elsewhere. In this case you want them to be in the document, not in normal.dotm or in the document template if that is something other than normal.dotm.
Reply With Quote
  #9  
Old 04-28-2012, 09:20 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default Macro for prompting the event in word

Hi Paul,

Hope this one is fine.

Regards

Umesh Banga
Attached Files
File Type: doc PromptEventMacro.doc (30.5 KB, 9 views)
Reply With Quote
  #10  
Old 04-29-2012, 03:04 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: 21,962
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,

You'll need to save the file as a template. Here 'tis as Normal.dot (zipped):
Attached Files
File Type: zip Normal.zip (5.8 KB, 11 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 04-29-2012, 05:07 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default Prompt Event Macro

Hi Paul,

I have followed your instructions. Please see attached.

In case it does not work I have also attached the screenshots.

Regards

Umesh
Attached Images
File Type: png PromptEventModule.PNG (33.8 KB, 12 views)
File Type: png PromptEvent Class.PNG (41.7 KB, 11 views)
Attached Files
File Type: zip PromptEventMacro[1].zip (10.3 KB, 8 views)
Reply With Quote
  #12  
Old 04-29-2012, 05:19 PM
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: 21,962
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,

I should have been clearer - it needs to be in the Normal template or, perhaps, another global template or addin. The code has to load when Word starts, otherwise the class event doesn't get registered.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 04-29-2012, 06:13 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default

I have checked my normal.dot template, and i can see this in macro list.

it still give the same error message"compile error: User defined type not defined and highlights the line:

"Dim wdAppClass As New ThisApplication"

Regards
Reply With Quote
  #14  
Old 04-29-2012, 06:17 PM
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: 21,962
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

Have you replicated the code in your Normal template exactly as it appears in the attachment to post #10? That template works for me, so the same code should work for you.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 04-29-2012, 07:10 PM
ubns ubns is offline Prompt when close the document Windows 7 32bit Prompt when close the document Office 2010 32bit
Competent Performer
Prompt when close the document
 
Join Date: Apr 2012
Posts: 177
ubns is on a distinguished road
Default

I did actually. Anyways, it definitly something on my side.


any other way?
Reply With Quote
Reply

Thread Tools
Display Modes


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 12:09 AM.


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