Stop VBA code and return?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have a form that collects values, then sends those values to a Word
document. This works like a charm. I've been asked to have this Word doc
automatically save, which is fine. I can have the code write to the document
and save it to a specified directory. No problems there.

I'm anticipating the user wanting to potentially edit the Word doc before
saving. I know I can interrupt the VBA code with a Stop command, then
restart with the Run button from within the VBA editor.

What I'd like to have is code that allows VBA to stop the code and allow the
user restart the code to finish the save process, all without having the user
see/manipulate the VBA editor.

I'd appreciate any ideas. :)

Thanks very much,
Paul
 
Just an idea for a work around. Could you save the document then open it in
Word for editing? If the user makes changes, Word will then prompt them to
save when they try to close Word.
 
Hey Wayne,

Thanks for the response.

I could absolutely do as you suggested, and have considered it. But, it's
been my experience that this person for whom I'm doing this database is
treating it as a mystical entity, about which he'll happily remain blithely
ignorant, so I'm trying to anticipate as much as humanly possible.

I'm not sure if this is even possible, but I guess what I'd like to have
happen is have a code "break" of some kind that hides the VBA editor window,
then waits for a singular input (button, etc) from the user to resume the
code.

Does that make a lick of sense?

Thanks again.
 
There are only two ways I can think of to do that.

1) Break the routine into 2 routines. The second part would be in the Click
event of the button.

2) Place a loop in the code that will cause it to keep checking for some
value to change. When it changes, exit the loop. Change the value in the
button's Click event. You would have to put a DoEvents statement in the loop
to let other things continue to run while you're waiting. I haven't tried
this, so it may not work.

Saving the document first then opening it would "appear" the same to the
user, except it won't ask to save if they close it without making changes.
If you need to work around that, then "dirty" the document. Open it and add
a character to it then remove the character. The only other thing I can
think of would be to fully take control of the Word document with DDE or OLE
commands. I don't know how to do this, but from what I understand, it is a
lot of work.
 
Hey Wayne, and anyone else that reads this, check this out.

I was just toolin' around and came upon this helpful tip:

http://www.mvps.org/access/forms/frm0014.htm

I created a modal form with a single label containing a message to the user
to edit the document created by the code, if they desire, then just close the
form to resume the process.

Kinda cool, wouldn't you say? :)

Paul
 
Yes, you can open an Access form using the acDialog argument and that will
suspend the code until you close or hide the form. You were wanting to do
this with Word, not an Access form. However, I suppose that you could use
this popup form to suspend the code. When the user is done with work they
could click a button on this popup form to indicate that they are done. This
would close the form and allow the code to continue. Be aware that such a
form will be application modal, meaning that you won't be able to do
anything else in Access until you respond to this form I'm not sure how Word
would respond if you opened it using the same code as the popup form but
before you opened the popup form. It may be tied to Access and the popup
would block Word from being used. If this is the case, you could probably
open Word from the popup.
 
Back
Top