"You cannot open two documents with the same name" problem and how totrap the error in VBA.

A

Anthony

Hi All,

I am wondering if anyone has a solution on this.

There is a Word 2007 file (docx) that has links to an Excel file.
They are both resided in the same folder. When the files are moved
to
another folder, the link path does not get updated – which I
understand. But when the Word file is first opened, the following
message came up:

A document with the name "xxx.xlsm" is already open. You cannot open
two documents with the same name, even if the documents are in
different folders. To open the second documents, either close the
document that's currently open, or rename one of the documents.

(Notice that it does not matter if the source file is xlsm or xlsx.)

This message would come up for every links in the file. One has to
keep clicking the [Ok] button to by pass this. If there are 100
links
in the file, one would have to click 100 times. Unfortunately, there
are over 100 files like that and some may contains hundreds of
links.

(Also, when the Word docx is opened, Excel also came up in the
background - as shown in the Windows Task Manager.)

The problem would occur whether the Excel source file is opened or
not. When I save the 2007 docx file into 2003 doc file, there is no
such problem for the 2003 doc file.

You may replicate the error following the simple steps below:
1. Create a link from an Excel xlsx or xlsm file (say in cell A1)
into
a Word 2007 docx (using paste special.. with the link button checked)
and save both files in “Folder 1”.
2. Copy the folder with the two files and rename the folder to
“Folder
2”.
3. Open the Word file from folder 2.

When you have done all these you will encounter the error.

I use VBA in Word to open the docx file and have the code run a check
to see if the particular xls file is opened or not. If it is pened,
then close it. But despite I have the code running, the "A document
with the name "xxx.xlsm" is already open" message still came up in the
beginning. The error message came up before the code can be executed
and I cannot trap it using error handler. When I use VBA to open the
docx file , I have Application.DisplayAlerts = wdAlertsNone in
the beginning before the Word file is selected and opened, but the
message still came up.

So what I need to know is how to programmatically bypass the error
message and how to trap the error. (If the error can be trapped then
it can be bypass.)

Could anyone help?


Anthony
 
M

macropod

Hi Anthony,

See reply in microsoft.public.word.vba.general.

Please don't post the same question multiple times in different newsgroups - you can post to multiple newsgroups simultaneously, if
need be, so that an answer in one newsgroup propagates to all.

--
Cheers
macropod
[Microsoft MVP - Word]


Hi All,

I am wondering if anyone has a solution on this.

There is a Word 2007 file (docx) that has links to an Excel file.
They are both resided in the same folder. When the files are moved
to
another folder, the link path does not get updated – which I
understand. But when the Word file is first opened, the following
message came up:

A document with the name "xxx.xlsm" is already open. You cannot open
two documents with the same name, even if the documents are in
different folders. To open the second documents, either close the
document that's currently open, or rename one of the documents.

(Notice that it does not matter if the source file is xlsm or xlsx.)

This message would come up for every links in the file. One has to
keep clicking the [Ok] button to by pass this. If there are 100
links
in the file, one would have to click 100 times. Unfortunately, there
are over 100 files like that and some may contains hundreds of
links.

(Also, when the Word docx is opened, Excel also came up in the
background - as shown in the Windows Task Manager.)

The problem would occur whether the Excel source file is opened or
not. When I save the 2007 docx file into 2003 doc file, there is no
such problem for the 2003 doc file.

You may replicate the error following the simple steps below:
1. Create a link from an Excel xlsx or xlsm file (say in cell A1)
into
a Word 2007 docx (using paste special.. with the link button checked)
and save both files in “Folder 1”.
2. Copy the folder with the two files and rename the folder to
“Folder
2”.
3. Open the Word file from folder 2.

When you have done all these you will encounter the error.

I use VBA in Word to open the docx file and have the code run a check
to see if the particular xls file is opened or not. If it is pened,
then close it. But despite I have the code running, the "A document
with the name "xxx.xlsm" is already open" message still came up in the
beginning. The error message came up before the code can be executed
and I cannot trap it using error handler. When I use VBA to open the
docx file , I have Application.DisplayAlerts = wdAlertsNone in
the beginning before the Word file is selected and opened, but the
message still came up.

So what I need to know is how to programmatically bypass the error
message and how to trap the error. (If the error can be trapped then
it can be bypass.)

Could anyone help?


Anthony
 

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