Microsoft Office Automation

R

Raju Joseph

Hi All,

We have a module that needs to automate word 2000 for certain added
functionality. I have successfully created the component to do this.
Basically I start word using a statement like

_word = New Word.Application

Then I proceed to sink the word events that I need.

Once everything is completed, I unsink the events and quit word using the
statement

_word.Quit( SaveChanges:=Word.WdSaveOptions.wdPromptToSaveChanges,
Missing.Value, Missing.Value)

Everything works fine except for a recent problem we discovered. If the user
has already an instance of word running, then when the code tries to quit
the automated word application, I get the following message

This file is in use by another application or user. (C:\Documents and
Settings\...\Normal.dot")

When I click Ok, it displays the SaveAs dialog. I cancel this dialog. Then
when I attempt to close the automated word application manually, I get the
following error message

Changes have been made that affect the global template, Normal.dot. Do you
want to save changes?

Could some one point me in the right direction to avoid these messages from
popping up. Is there any way I can turn off these messages or somehow
indicate that the global template Normal.dot has not been modified.

I am using Visual Studio .NET 2003 and Word 2000. In the automated word
application I am modifying the ways in which certain menus and toolbar
buttons of word should behave.

Thanks,

Raju
 
K

Kalpesh

Hi Raju,

Can you pls post the code ?
I will try & simulate this thing & see where the problem is occurring &
why ?

Kalpesh
 
R

Robin Tucker

You are prompting to save changes when you quit - of course it is going to
give you these message boxes.
 
P

Peter Bernhardt

All you need to do is set the Word option controlling this behavior using
the Options property of the Word application class instance.

Options.SaveNormalPrompt = False

I don't know if this option is available in Word 2000, but it should be. You
could also open an instance of Word and set this property manually before
running your program.
 
R

Raju Joseph

Okay,

I found the problem and fixed it.

Reason why Word was prompting me to save Normal.dot file because I modified
the default behavior of certain Word menus and toolbar buttons.

All I had to do was before closing the word application was to place the
following code

Application.NomalTemplate.Saved = True

everything seems to be okay.

Thanks a lot guys,
 

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