[AccessD] Automation of word

Max Wanadoo max.wanadoo at gmail.com
Tue Feb 5 11:12:02 CST 2008


John,
Checking Word Help...  This is a copy-n-paste.  You can just show them a
message saying "Close from Access, etc" and set the cancel = true as soon as
they try to close the document.
Max
ps. Haven't tried it.  Refer to the comments on this method.

DocumentBeforeClose Event
See AlsoApplies ToExampleSpecificsOccurs immediately before any open
document closes.

Private Sub object_DocumentBeforeClose(ByVal Doc As Document, Cancel As
Boolean)
object    An object of type Application declared with events in a class
module. For more information about using events with the Application object,
see Using Events with the Application Object.

Doc    The document that's being closed.

Cancel    False when the event occurs. If the event procedure sets this
argument to True, the document doesn't close when the procedure is finished.

Example
This example prompts the user for a yes or no response before closing any
document. This code must be placed in a class module, and an instance of the
class must be correctly initialized in order to see this example work; see
Using Events with the Application Object Using Events with the Application
Object for directions on how to accomplish this.

Public WithEvents appWord as Word.Application

Private Sub appWord_DocumentBeforeClose _
        (ByVal Doc As Document, _
        Cancel As Boolean)

    Dim intResponse As Integer

    intResponse = MsgBox("Do you really " _
        & "want to close the document?", _
        vbYesNo)

    If intResponse = vbNo Then Cancel = True
End Sub
	 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, February 05, 2008 4:16 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Automation of word

Max,

This doesn't work because the user gets to fill in stuff in the document,
and does so on a regular basis.  Thus the save would not show all their
changes to the document.  Yes, word prompts them just fine but they get to
say no.  Saying no is NOT LEGAL, but they can if they want to.  THAT IS THE
PROBLEM.  I need to "lock the document open" so that whether they say yes or
no, they can't close the document.  I can then take my pointer to the
document, force Word to save the document and then close it myself.


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Tuesday, February 05, 2008 10:19 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Automation of word

John,
Why don't you save the document within your code before opening it for the
user.  If you used a NEW Word Object then that object will remain extant
until the user closes it (the Word doc) at which point your code gets
control back and just clears the object.  All your work will have been done
before hand so no cleanup to do - just a matter of setting the object to
nothing.  if the user makes changes then word itself will prompt the user to
save or discard.  Your side of it is done.

Max 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, February 05, 2008 2:49 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Automation of word

Max,

I am really just trying to figure out how to keep control of the word
instance.  The only thing that comes to mind (other than William's
suggestion of running code inside word itself) is to somehow prevent my
instance of word from closing, thus forcing the user to switch back to
Access to let me have control again.  At that point I can save, close and
cleanup.

If you know how to prevent your instance of Word from closing I think that
would be enough.  Otherwise suggestions on how to do this are appreciated.


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo
Sent: Tuesday, February 05, 2008 9:20 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Automation of word

Well,  I can say that I do virtually all of that as well with the one
exception of user adding in comments during print time, but it would be easy
to implement that.
when I get time later, I will go through my routine and strip away the bits
that don't lend themself to what you are doing and then post it up.  It is a
very long routine which is why I was just posting bits out of it.
It is based on Bookmarks in Word dot (not docs, but template dot files).
There is a master Word Doc which people copy, give a new name to and add the
text in and put any other bookmarks in (from a series of known bookmark
names that the this system understands).  The calling form (but could be a
rst) is selected from a Combo (which letter do you want to send type thing).
The user can d/click on the selected letter and make changes if they want to
the  DOT document.  there are also clicks for paragraphs to be added in,
postscripts, donations, etc, etc.  A whole range of stuff.
When the module is called, it is passed the form name.   From that it will
know what sort of data is available and will open a NEW INSTANCE of word
object.  It will then create a new document based on the selected DOT
document and populate the bookmarks.  It will then create a new name which
is part system generated and part data orientated.  If a word document
exists with the same name, it will append a sequential number and loop until
it gets a unique name.  It then saves this.  It then background  prints and
stays there until the printing is completed (couple of millisecs typically)
and then closes the INSTANCE of the WORD Object.  A usesr can hage multiple
word documents open if they wish, no problem as  we are using our own
INSTANCE of the object.
The options are to Just Print it, Preview it, Cancel it.  The document name
is then written to a linked table (PersonID and LetterID).  it can be
retrieved at any time, previewed again, deleted etc - up to you).  All
letters we send out are done via the database so that we know exactly what
was sent, who sent it, etc.

Obviously, I can't post up the whole suite but the above should give you a
general feel.  Do you want the Word module posted or sent private (or not at
all)?

Max



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Tuesday, February 05, 2008 1:25 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Automation of word

Max,

In this case the user selects from one of dozens of different documents
specific to a type of disability claim for a specific disability insurance
company.  These documents are things like request for medical records,
notice of claim status, legal requests to lawyers, what have you.  So the
user selects a specific document, then the people that will get a copy of
the document, who the "to" is, and who are CCs etc.  They then click a
"merge" button and the data required for that specific document is dumped to
the text file, Word is opened with that specific document loaded.  Word
pulls the data from the text file and then MAY throw up prompts to the user
to fill in other data that is not in tables, but rather is in the claim
processor's head (comment to the claimant etc).  

Once the claim processor has finished and is happy with the document, (s)he
prints the document and closes word.  Thus the process is a little more
complex than just "open and print a document".  

What I am trying to accomplish now is to reliably get the document saved
after being filled in, as well as reliably get Word closed.  This
application is call center software.  My client, the user of the
application, has invested in a system to scan all paper and get it into
electronic format.  The claim is a paper file, the document just created is
printed, but the paper is never touched after being placed in the folder.
All processing of the claim is done by looking at the document scans.  The
entire claim is dumped to individual DVDs and those DVDs are sent to their
client (large insurance companies).  The paper is sent to dead storage, it
has to exist for legal reasons but it never has to be actually looked at.

So... ATM the process of SAVING the document relies on the user to actually
do so.  The document HAS to be saved to a specific folder in order for the
scan software to "see it".  That software will open all documents in a
specific folder and import it into the document storage system, index it by
claim number etc.  But if the document does not get saved, then it does not
get into the electronic version of the claim.  ATM they take the paper copy
just printed, place it into a scanner and manually scan the paper into the
system but that is labor intensive.  They do a thousand documents a day, and
they want to be able to reliably save the document into this special folder
and just let the doc storage do its thing without having to go through that
manual scan step.

Additionally closing of the WORD application depends on the user.  I want to
gain control of the save and the close process.  Thus I want to lock Word
open and force the user to click a button in Access so that my program can
save the document close Word and release my pointer to word, log that I
saved the document to doc storage etc.


John W. Colby
Colby Consulting
www.ColbyConsulting.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list