Exit Macro

A

ah

I've inserted a macro to capture the value as negative amount when I exit the
amount field.

However, I found that the user did not leave the field before they save the
file. As a result, the macro is not running since they did not exit that
field.

Please advice what should I do to ensure that the macro is running even when
the suer did not exit that field.

Thanks a lot!
 
G

Graham Mayor

If you don't exit the field the exit macro won't run - that's why its called
an exit macro! Use any entry macro to tell the user to tab out of the field.

Sub PopUpAdvice()
Dim sMsg As String
sMsg = "Tab out of this field on completion," & vbCr & _
"to ensure that it is correctly formatted"
MsgBox sMsg, vbOKOnly, "User instructions"
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Gordon Bentley-Mix

You could also possibly try calling the exit macro in a FileSave, FileSaveAs
or Document_Close macro...
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
A

ah

Hi Gordon;

Thanks for your reply.
This sounds good. I would appreciate if you could provide me with the code
as I'm not familiar with macro coding.

Thanks in advance.
 
A

ah

Thanks a lot for your kind help.

Is it possible for us to get the macro to run when the user save the file?

Please advice.
 
G

Gordon Bentley-Mix

At its most basic, the macros would look something like this:

Sub FileSave
Call MyExitMacro
ActiveDocument.Save
End Sub

Sub FileSaveAs
Call MyExitMacro
Dialogs(wdDialogFileSaveAs).Show
End Sub

These would go into any VBA module - most likely the one that already
contains your exit macro - and would effectively intercept the File | Save
and File | Save As commands. You would, of course, replace "MyExitMacro" with
the name of the exit macro you have already developed.

Note, too, that the "Call" statement is not absolutely necessary; I only
included it for clarity.

In addition, you may also have to do a bit of fiddling around with your exit
macro to make sure it can be invoked using this method if it's not in the
same module as the sample code above.

Using the Document_Close event as the trigger would be a bit more
complicated and requires an understanding of VBA that may be beyond the
current scope of your learning. I would recommend that you do a bit of study
before attempting this approach.

In fact, it probably wouldn't do any harm to build your knowledge generally
if you plan on doing more of this type of work. Forum members are all unpaid
volunteers and, while they are happy to help, you may find they get a bit...
testy... if you don't show a willingness to help yourself in the first
instance. Otherwise, I would suggest engaging an outside resource to assist
you.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
G

Graham Mayor

Gordon has that covered :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

ah

Hi Gordon;

Thanks a lot for your kind help!!!
It works and I'm so excited!

Thanks a lot!

Regards;
A.H
 
A

ah

Thanks a lot!
You're so helpful! :)

Graham Mayor said:
Gordon has that covered :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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