J
Joanne
I have this routine that opens several docs in msword.
The user then views and/or prints the docs one at a time, then closes
each of them. When the viewer closes the last doc, I would like to
close msword and clean up programmatically.
This is the code I am using:
If Not oRst Is Nothing Then
Do While Not oRst.EOF
sfilename = "" & oRst("DocNamePath")
If Len(Dir$(sfilename)) > 0 Then
oWordapp.Visible = True
Set oDocName = oWordapp.Documents.Open(sfilename)
End If
oRst.MoveNext
Loop
End If
oRst.Close
oWordapp.Quit
Set oWordapp = Nothing
Set oDocName = Nothing
Set oRst = Nothing
Problem is it goes thru everything nicely, but closes and cleans up
before the viewer has had a chance to do any work.
I don't know how to program it so that it knows when the last file has
been closed so that it can do its job at that point instead of
immediately.
I tried putting the last 5 lines in an if/end if loop, setting it to
If Len(Dir$(sfilename)) = 0 Then
but that didn't work, so I tried setting the line to read when
If oRst Is Nothing Then
but that also didn't work.
Could you please give me a hand with this, or show me where to read up
on it and help myself?
Thanks
Joanne
The user then views and/or prints the docs one at a time, then closes
each of them. When the viewer closes the last doc, I would like to
close msword and clean up programmatically.
This is the code I am using:
If Not oRst Is Nothing Then
Do While Not oRst.EOF
sfilename = "" & oRst("DocNamePath")
If Len(Dir$(sfilename)) > 0 Then
oWordapp.Visible = True
Set oDocName = oWordapp.Documents.Open(sfilename)
End If
oRst.MoveNext
Loop
End If
oRst.Close
oWordapp.Quit
Set oWordapp = Nothing
Set oDocName = Nothing
Set oRst = Nothing
Problem is it goes thru everything nicely, but closes and cleans up
before the viewer has had a chance to do any work.
I don't know how to program it so that it knows when the last file has
been closed so that it can do its job at that point instead of
immediately.
I tried putting the last 5 lines in an if/end if loop, setting it to
If Len(Dir$(sfilename)) = 0 Then
but that didn't work, so I tried setting the line to read when
If oRst Is Nothing Then
but that also didn't work.
Could you please give me a hand with this, or show me where to read up
on it and help myself?
Thanks
Joanne