Re: Word automation, etc.
- From: "wilsond" <wilsond@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Dec 2005 14:15:03 -0800
Hi Cindy,
Thanks so much for your input. I appreciate it!
Off the current subject, I was having a bit of trouble closing out the word
instance. I don't understand why it didn't work the way I had it and after a
modification to the code it does work now. Basically, when the application
starts it creates an instance of word. If I then quit the application before
a document was loaded, the word instance wouldn't die. If a document is
loaded first then the app is quit, the word instance goes away.
Anyway, here is the previous code (that wouldn't kill the word instance):
public void CloseControl()
{
object dummy = System.Reflection.Missing.Value;
object dummy2 = (object)false;
try
{
document.Close( ref dummy2, ref dummy, ref dummy );
wd.Quit( ref dummy2, ref dummy, ref dummy );
}
catch {}
}
This would give the "The Object invoked has disconnected from the clients"
error when I would quit the app without loading a document.
When I changed the code such that the .Close and .Quit methods were in
separate try/catch blocks, the instance of word is killed and I don't get the
error.
public void CloseControl()
{
object dummy = System.Reflection.Missing.Value;
object dummy2 = (object)false;
try
{
document.Close( ref dummy2, ref dummy, ref dummy );
}
catch {}
try
{
wd.Quit( ref dummy2, ref dummy, ref dummy );
}
catch{}
}
Any ideas why this happens?
David
"Cindy M -WordMVP-" wrote:
> Hi =?Utf-8?B?d2lsc29uZA==?=,
>
> > We will
> > be using Word 2003. The development environment is .NET (2003) and C#.
> >
> OK, this opens up additional possibilities for you. One is XML. You could,
> for example, dump all the document content and formatting into a "blank"
> document in the form of XML. This won't carry across everything (some of
> the page layout stuff, for example), but it would certainly be faster than
> automating the creation of a document from scratch. (This in answer to
> creating a new document from a URL, via d/l from a Web Server).
>
> You can also extract the content of a document the same way. Or, if you
> don't need the entire document, just certain parts, you can parse the XML
> and extract only what you need.
>
> > I have to check with the super on the tab key issue. I don't know if she
> > will allow me to use anything other than tab. If that's the case, I'll
> > probably go the keybindings/macro route...
> >
> Word 2003 provides a special kind of document protection: you can
> lock/unlock specific document ranges for editing. There's a task pane that
> lets the user move from editable area to editable area.
>
> There's also the possibility of protecting a document as a form and using
> Form Fields (then you can TAB). And there are ActiveX controls that can be
> used with forms protection. The biggest issue with forms protection comes
> if the user needs to do more than just enter text content. Formatting,
> headers, footers and graphics (basically) are locked out with forms
> protection active.
>
> What might be very interesting for you would be VSTO 2005 (for that, you
> need VS 2005), where you can use data-caching, create custom task panes and
> provide a wide range of controls (including Windows controls you create
> yourself).
>
> SmartDocument solutions might also be something for you to consider
> (especially if VSTO 2005 isn't an option). There you place XML tags in your
> document. You then define what should appear in a special task pane to aid
> the user with the expected in-put. (Including displaying lists from
> databases, and even sending data back through the list.)
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
> http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
>
>
.
- Follow-Ups:
- Re: Word automation, etc.
- From: Cindy M -WordMVP-
- Re: Word automation, etc.
- References:
- Word automation, etc.
- From: wilsond
- Re: Word automation, etc.
- From: Cindy M -WordMVP-
- Re: Word automation, etc.
- From: wilsond
- Re: Word automation, etc.
- From: Cindy M -WordMVP-
- Word automation, etc.
- Prev by Date: Can't get excel Ranges to work using (Visual) C++
- Next by Date: Automation objects specific to windows version ?
- Previous by thread: Re: Word automation, etc.
- Next by thread: Re: Word automation, etc.
- Index(es):
Relevant Pages
|