Word 2007 + programmatic second instance thru VB.Net 2005

K

koms

hi Bob,

thanks for the prompt reply... no this hasn't helped solved my issue. Maybe
i should be a bit more precise.
I am not trying to edit the .dotm file (template) , its being loaded as you
would expect word to load all templates,macros, add-ins etc. What i wanted to
know was that word2000 - 2003 has a different behaviour in that i could have
one document open and then also create a second instance thru
CreateObject("Word.Application") and work with this instance in the
background.
In this case i did not have to check if there was an existing instance of
word already present and i did not have to piggy back on that instance. I
could always create a second independent instance of winword.exe and work
with that.
Has this behaviour changed with Word 2007 !!! coz presently it seems i cant
create an independent session of winword i.e two instances of winword.exe
without running into the template locked issue ( even when i am not trying to
edit the template !! ).

One possible work around to the issue i face is to use
GetObject(,"Word.Application") to get existing instances if they are loaded
and work with it. The issue with this approach is previously we have always
created new session of winword so that we can control everything and just
exit when we're finished using it. How can i try n acheive this with Word
2007.

I hope i have been able to put across the issue if not please do not
hesitate to ask !!
thanks in advance.

cheers
koms

=========================
Hi Koms,

You may want to use the link below to also post this in the Word Programming
discussion group.

Starting Word with no visible new document does not prevent the templates in
the Startup folder from being attached to and
accessible to Word (Alt, T, I) and a Windows 'in use' lock file is created
at that point (check the Startup folder for the lock
file - hidden file named ~MyDotM.dotm with your example). The template can
be edited through the use of the Document Building
Blocks, macros and other means and Word doesn't support multiple uses of the
same file whether it's by two users or two instances
for the same user.

While Word also creates lock files for any Word 97-2003 format .dot files in
the Word 2007 Startup folder it doesn't raise the
warning on starting Word for those. (Use File=>Save as with your MyDotM.dotm
to save another copy to \STARTUP as MyDotm.DOT (Word
97-2003 template). It may, however, 'wait' to warn you that two copies are
in use when you try to save a change that was made to it.
:)

If you start a new document from the 1st instance and use Insert=>Quick
Parts=>Building Blocks Organizer then close that dialog then
repeat that in the 2nd instance you'll likely get the same message for other
2007 templates (not in the startup folder) at that
point. If one of those templates is a .dot file, then that would be one
where you can likely edit a building block in both copies
and get the warning only when you try to close out the Word session.

==============
hi everyone !!

I have run into a problem that appears to be a bug in Word 2007.

If I save a .dotm file in Word's startup folder, the file seems to get
locked by Word while Word is open, which is OK. The problem is that when I
open another instance of Word, word complains that the .dotm is locked for
editing, when it really isn't. I am doing this thru my vb app !!

I know that there are plenty of applications that install templates in
Word's Startup folder, and there are also many situations where more than one
instance of winword.exe is running, so I'm kind of surprised that I couldn't
find anything about this in the knowledgebase or newsgroups.

Here are the steps to reproduce the problem (using the released version of
Word 2007 on Windows XP):

1. Open Word 2007. Save the untitled document as:
C:\Documents and Settings\username\Application
Data\Microsoft\Word\STARTUP\MyDotm.dotm

2. Close the document and close Word.
3. Go to Start > Run, type "winword /n", and click OK. Word Opens with no
open document (/n means don't start with an empty document).
4. Repeat step 3 (Go to Start > Run, type "winword /n", and click OK.

Error: A new instance of word opens (which is correct), but the following
dialog comes up from Word:

Do you want to:
Open a Read Only copy
Create a local copy and merge your changes later
Receive notification when the original copy is available"

has anyone else run into this problem ???... this was posted by somebody
somewhere else as well (a site called awomantoldme) n still havent found a
solution to this !!!

******* Hope the MVP's can help out here !!!!! *********

cheers >>
--
Please let us know if this has helped,

Bob Buckland ?:)
MS Office System Products MVP

LINKS
A. Specific newsgroup/discussion group mentioned in this message:
news://msnews.microsoft.com/microsoft.public.word.programming
or via browser:

http://microsoft.com/communities/newsgroups/en-us/?dg=microsoft.public.word.programming

B. MS Office Community discussion/newsgroups via Web Browser
http://microsoft.com/office/community/en-us/default.mspx
or
Microsoft hosted newsgroups via Outlook Express/newsreader
news://msnews.microsoft.com


=================================
 
T

Tony Jollans

It seems to me that Bob has given you the answer. Strictly this is not a
change in behaviour as dotms didn't exist before 2007 but it is a different
behaviour for dotms and dots. As far as I know there is nothing you can do
to avoid the issue, and there are other issues with it as well. Whether it's
a bug, or not, is probably open to debate.
 
B

Bhavin Shah

Hi there,

Koms is my coleague and we both failed to understand the answer given by Bob..

Here is the simple way of reproducing our problem which will give u a better
idea about the actual problem..

Follow the steps below..

1. Open a blank word 2007 document and SaveAs "xyz.dotm" (macro enabled
template) at the following location: C:\Program Files\Microsoft
Office\Office12\Starup

(this template does not need to have any macros in it..)

2. Now open a blank word document and leave it open... (first instance of
word 2007 document)

3. And now goto Start -> Run and type the following command "winword /w"

(this command will start a second instance of word 2007 document and opens a
blank document)

PROBLEM -- you will notice a dialog box saying the template (XYZ.DOTM in the
startup folder) is locked for editing ...!!

4. Our question is this behaviour is abnormal as compared with the previous
the versions of word where we have our templates (.dot) files at the same
Starup location and no matter how many instances we create of word document
there were no such dialog boxes..

-- is this something new from Microsoft with .dotm (or .dotx) templates or
is this a bug of Microsoft Word 2007

... PLS HELP US ..

thx

Billy
 
T

Tony Jollans

Hi Bravin,

I'm not sure what you don't understand. You may not like the answer but what
don't you understand about it?

The problem exists - I know about it, Bob knows about it, you know about it.

Is it a bug? I don't know. What can you do about it? I don't know that
either. Attaching to an existing instance, if there is one, may work for
you - it depends on your circumstances.
 
B

Bhavin Shah

Hi Tony,

thx for the reply..

here is the part we don't understand from Bob's reply..
"The template can be edited through the use of the Document Building Blocks,
macros and other means and Word doesn't support multiple uses of the same
file whether it's by two users or two instances for the same user......"

-- we are not trying to edit the template.. the template is in the word
startup folder, hence will attached to any word document --

our question is "What is different in the new template formats (.dotm and
..dotx)? and why can't you attach more than one instance of word document to a
global template!!"

** i found a quick fix by MAKING THE .DOTM OR .DOTX TEMPLATE READONLY IN THE
STARTUP FOLDER and it behaves normally.. but what i am after is a bit more
detail explanation about the new formats in word 2007 templates and if there
are any other settings which can make a global template behave as expected??

Regards,

Bhavin
 
B

Bob Buckland ?:-\)

Hi Bhavin,

The behavior also happens in Word 2003, but when you encounter it can depend on what is being done with an attached template. What
could happen is that someone could be happily working along and not realized that they had made a change that impacted a .dot file
until they went to close the document or Word and started getting the 'you can't do that' messages. Now you'd have to figure out
what 'that' was and work your way back.

What appears to be happening with the .dotx and .dotm templates is that Word is putting them into 'in use' state as they're loaded.
That could be from the process of opening their XML format and making it available within Word (a step that .dot files don't use).

That the file is open in an editing program makes it 'in use for editing', so changing the attribute to 'read only' may be of use,
but Word will still allow making changes to the 'read only' template, up to the point where you try to close and accept the changes
to the global template.

Document Parts in Word (36 separate galleries, an expansion of AutoText) read each attached template to look for entries, and also
to hold open in
Insert=>Quick Parts=>Document Parts
each of the attached templates for editing (i.e. add, edit properties, move entries, etc between any attached templates) as soon as
any of the galleries of organizer are opened.

==========
Hi Tony,

thx for the reply..

here is the part we don't understand from Bob's reply..
"The template can be edited through the use of the Document Building Blocks,
macros and other means and Word doesn't support multiple uses of the same
file whether it's by two users or two instances for the same user......"

-- we are not trying to edit the template.. the template is in the word
startup folder, hence will attached to any word document --

our question is "What is different in the new template formats (.dotm and
..dotx)? and why can't you attach more than one instance of word document to a
global template!!"

** i found a quick fix by MAKING THE .DOTM OR .DOTX TEMPLATE READONLY IN THE
STARTUP FOLDER and it behaves normally.. but what i am after is a bit more
detail explanation about the new formats in word 2007 templates and if there
are any other settings which can make a global template behave as expected??

Regards,

Bhavin>>
--

Bob Buckland ?:)
MS Office System Products MVP

*Courtesy is not expensive and can pay big dividends*
 

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