![]() |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
Yes, but it's not a trivial process. See: http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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] |
#5
|
||||
|
||||
![]()
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 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 Code:
Dim wdAppClass As New ThisApplication Public Sub AutoExec() Set wdAppClass.wdApp = Word.Application End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
Hi Paul,
Please see the attached document, it gives some error message. Regards Umesh |
#7
|
|||
|
|||
![]()
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.
|
#8
|
|||
|
|||
![]()
Hi Paul,
Hope this one is fine. Regards Umesh Banga |
#9
|
||||
|
||||
![]()
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] |
#10
|
||||
|
||||
![]()
Hi umesh,
You'll need to save the file as a template. Here 'tis as Normal.dot (zipped):
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
![]()
Hi Paul,
I have followed your instructions. Please see attached. In case it does not work I have also attached the screenshots. Regards Umesh |
#12
|
||||
|
||||
![]()
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] |
#13
|
|||
|
|||
![]()
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 |
#14
|
||||
|
||||
![]()
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] |
#15
|
|||
|
|||
![]()
I did actually. Anyways, it definitly something on my side.
any other way? |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
KJJ | Word VBA | 14 | 11-10-2016 08:18 PM |
![]() |
UTSUPPORT | Word | 1 | 01-16-2012 09:27 PM |
![]() |
MikeWooZ | Excel | 6 | 12-04-2011 02:10 PM |
![]() |
caddcop | Word VBA | 3 | 06-14-2011 05:45 PM |
Disable email security prompt | mcinnes01 | Outlook | 1 | 03-17-2011 07:00 AM |