Identify the word document and closing it

  • Thread starter sirumalla.srinivas
  • Start date
S

sirumalla.srinivas

Frens,

My project is combing the content of two forms (lets say A & B form)
doing little modifications .

1. Form A individually prints a word document once the user enters the
reuqired info and comes out of the form A
2. Form B individually prints a word document once the user enters the
reuqired info and comes out of the form B

Now i need to do modifications in such away that once the user comes
out of Form A, The control should open Form B, User enters the required
info, once he comes out of form B, we need to print the content of A
and B in the single document.

1. I am able to do this, but i found some problems while testing

#1. When the control comes from Form A to Form B, I need to close the
word document which was opened by Form A. For closing the document I
have coded in Form B

Dim Doc2 As Word.Document
Set Doc2 = CreateObject("C:\xxxx Forms\xxx\xxxx\xxx.dot")
Doc2.Close (wdDoNotSaveChanges)
Set Doc2 = Nothing

Iam able to close the document but that instance (winword.exe) is still
running in the task manager even after closing the document.

I tried GetObject instead of CreateOcject but it throwed an error
saying that "Document is already opened"

#2. In Form B i need to identify the document which is opened by Form A
and close that document associated to Form A alone.

In #1 i was able to close the document since i know the path, but in
real time in need find the documents which are all opened, get the
title or caption of the document, match it with Form A document and
close the particular document.

Your help is highly appreciated.

Pls help me in #1 and #2

Thanks
Srini
 
D

Doug Robbins

Is this being done from Word?

If so, use

Dim Doc2 as Document
Set Doc2 = Documents.Add("C:\xxxx Forms\xxx\xxxx\xxx.dot")
etc.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - 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