472,108 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,108 software developers and data experts.

Quitting "Word.Application" Help Please

Hi

Im doing something wrong in quitting the Word.Application in my VB program.
I have

General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me

When I click Exit to end my program Winword.exe is still running as a
process listed in my Task Manager. Not only is it listed, but the process is
taking up 100% of my CPU usage.
How do I end the Word.Application correctly ???

Thanks
Trevor.
Jul 17 '05 #1
5 13424
The first thing I see is that you are using a mix of Early and Late binding
to create your object.

This is your code as it stands:
General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me
In early binding mode it should be: General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = New Word.Application

In Late Binding mode (using createobject()) it should be: General Declarations
Dim AppWord As Object

Form_Load()
Set AppWord = CreateObject("Word.Application")
Try the same code to end your word application object as you have with one
of these two declarations (early or late binding). and see if it still
causes a problem.

--
Stéphane Richard

"The Roys" <tr*****@hotmail.com> wrote in message
news:VK********************@news-server.bigpond.net.au... Hi

Im doing something wrong in quitting the Word.Application in my VB program. I have

General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me

When I click Exit to end my program Winword.exe is still running as a
process listed in my Task Manager. Not only is it listed, but the process is taking up 100% of my CPU usage.
How do I end the Word.Application correctly ???

Thanks
Trevor.

Jul 17 '05 #2
Thanks for your reply, but either way makes no difference. Before exiting,
and while program is dormant the process in the Task Manager (Winword.exe)
does not take up any CPU usage. But as soon as I run the Exit code the CPU
usage goes to 100% and the process is still in the Task Manager.
Every time I run the program a new Winword.exe process begins.

Any ideas ??
"Stephane Richard" <st**************@verizon.net> wrote in message
news:QE******************@nwrdny03.gnilink.net...
The first thing I see is that you are using a mix of Early and Late binding to create your object.

This is your code as it stands:
General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me
In early binding mode it should be:
General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = New Word.Application


In Late Binding mode (using createobject()) it should be:
General Declarations
Dim AppWord As Object

Form_Load()
Set AppWord = CreateObject("Word.Application")

Try the same code to end your word application object as you have with one
of these two declarations (early or late binding). and see if it still
causes a problem.

--
Stéphane Richard

"The Roys" <tr*****@hotmail.com> wrote in message
news:VK********************@news-server.bigpond.net.au...
Hi

Im doing something wrong in quitting the Word.Application in my VB

program.
I have

General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me

When I click Exit to end my program Winword.exe is still running as a
process listed in my Task Manager. Not only is it listed, but the

process is
taking up 100% of my CPU usage.
How do I end the Word.Application correctly ???

Thanks
Trevor.


Jul 17 '05 #3
Just my guess:

Is there some code create a varable (probably at form level) that references
object in Word.Application somewhere between Foam_Load and cmdExit_Click,
which is still alive (not set to Nothing)?

If you simply try to start Word.Application and close it in the same
procedure, like below, I'll bet Word.Application would quit cleanly:

Private Sub cmdTest_Click()

Dim AppWord As Word.Application

Set AppWord=New Word.Application 'You can use CreateObject() if you
wish

MsgBox "Word launched"

AppWord.Quit;
'....................
End Sub

If Word.Application quits correctly here, then find some code in your
project that has something to do with AppWord before cmdExit_Click

"The Roys" <tr*****@hotmail.com> wrote in message
news:oV********************@news-server.bigpond.net.au...
Thanks for your reply, but either way makes no difference. Before exiting,
and while program is dormant the process in the Task Manager (Winword.exe)
does not take up any CPU usage. But as soon as I run the Exit code the CPU
usage goes to 100% and the process is still in the Task Manager.
Every time I run the program a new Winword.exe process begins.

Any ideas ??
"Stephane Richard" <st**************@verizon.net> wrote in message
news:QE******************@nwrdny03.gnilink.net...
The first thing I see is that you are using a mix of Early and Late

binding
to create your object.

This is your code as it stands:
General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me


In early binding mode it should be:
General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = New Word.Application


In Late Binding mode (using createobject()) it should be:
General Declarations
Dim AppWord As Object

Form_Load()
Set AppWord = CreateObject("Word.Application")

Try the same code to end your word application object as you have with one of these two declarations (early or late binding). and see if it still
causes a problem.

--
Stéphane Richard

"The Roys" <tr*****@hotmail.com> wrote in message
news:VK********************@news-server.bigpond.net.au...
Hi

Im doing something wrong in quitting the Word.Application in my VB

program.
I have

General Declarations
Dim AppWord As Word.Application

Form_Load()
Set AppWord = CreateObject("Word.Application")

cmdExit_Click()
AppWord.Quit
Set AppWord = Nothing
Unload Me

When I click Exit to end my program Winword.exe is still running as a
process listed in my Task Manager. Not only is it listed, but the

process
is
taking up 100% of my CPU usage.
How do I end the Word.Application correctly ???

Thanks
Trevor.



Jul 17 '05 #4
Yes Norman, You are absolutely correct. I am using the the spell checker in
word. If the spell checker is not used then the Winword.exe process does
close correctly.
Ok, now how do I close it down correctly if I do use the spell checker. The
spell checker code I have is:
If (AppWord.CheckSpelling(searchWord) Then
'This is a word -
count = count + 1
End If
This is the only code in my program which accesses Winword.
Do I also need to close the CheckSpelling process ???

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message
news:oMCjb.109482$pl3.80542@pd7tw3no...
Just my guess:

Is there some code create a varable (probably at form level) that references object in Word.Application somewhere between Foam_Load and cmdExit_Click,
which is still alive (not set to Nothing)?

If you simply try to start Word.Application and close it in the same
procedure, like below, I'll bet Word.Application would quit cleanly:

Private Sub cmdTest_Click()

Dim AppWord As Word.Application

Set AppWord=New Word.Application 'You can use CreateObject() if you
wish

MsgBox "Word launched"

AppWord.Quit;
'....................
End Sub

If Word.Application quits correctly here, then find some code in your
project that has something to do with AppWord before cmdExit_Click

"The Roys" <tr*****@hotmail.com> wrote in message
news:oV********************@news-server.bigpond.net.au...
Thanks for your reply, but either way makes no difference. Before exiting,
and while program is dormant the process in the Task Manager (Winword.exe) does not take up any CPU usage. But as soon as I run the Exit code the CPU usage goes to 100% and the process is still in the Task Manager.
Every time I run the program a new Winword.exe process begins.

Any ideas ??
"Stephane Richard" <st**************@verizon.net> wrote in message
news:QE******************@nwrdny03.gnilink.net...
The first thing I see is that you are using a mix of Early and Late

binding
to create your object.

This is your code as it stands:
> General Declarations
> Dim AppWord As Word.Application
>
> Form_Load()
> Set AppWord = CreateObject("Word.Application")
>
> cmdExit_Click()
> AppWord.Quit
> Set AppWord = Nothing
> Unload Me

In early binding mode it should be:
> General Declarations
> Dim AppWord As Word.Application
>
> Form_Load()
> Set AppWord = New Word.Application
>

In Late Binding mode (using createobject()) it should be:
> General Declarations
> Dim AppWord As Object
>
> Form_Load()
> Set AppWord = CreateObject("Word.Application")
>
Try the same code to end your word application object as you have with

one of these two declarations (early or late binding). and see if it still causes a problem.

--
Stéphane Richard

"The Roys" <tr*****@hotmail.com> wrote in message
news:VK********************@news-server.bigpond.net.au...
> Hi
>
> Im doing something wrong in quitting the Word.Application in my VB
program.
> I have
>
> General Declarations
> Dim AppWord As Word.Application
>
> Form_Load()
> Set AppWord = CreateObject("Word.Application")
>
> cmdExit_Click()
> AppWord.Quit
> Set AppWord = Nothing
> Unload Me
>
> When I click Exit to end my program Winword.exe is still running as a > process listed in my Task Manager. Not only is it listed, but the

process
is
> taking up 100% of my CPU usage.
> How do I end the Word.Application correctly ???
>
> Thanks
> Trevor.
>
>



Jul 17 '05 #5
I have just solved my problem.
I have accessed the Spell Checker via Excel rather than Winword, and the
process closes correctly.
Is this a bug with Winword, or a bug in my Winword, don't know, don't really
need to know now.

Thanks for your help guys.

"The Roys" <tr*****@hotmail.com> wrote in message
news:At********************@news-server.bigpond.net.au...
Yes Norman, You are absolutely correct. I am using the the spell checker in word. If the spell checker is not used then the Winword.exe process does
close correctly.
Ok, now how do I close it down correctly if I do use the spell checker. The spell checker code I have is:
If (AppWord.CheckSpelling(searchWord) Then
'This is a word -
count = count + 1
End If
This is the only code in my program which accesses Winword.
Do I also need to close the CheckSpelling process ???

"Norman Yuan" <no********@RemoveThis.shaw.ca> wrote in message
news:oMCjb.109482$pl3.80542@pd7tw3no...
Just my guess:

Is there some code create a varable (probably at form level) that references
object in Word.Application somewhere between Foam_Load and cmdExit_Click,
which is still alive (not set to Nothing)?

If you simply try to start Word.Application and close it in the same
procedure, like below, I'll bet Word.Application would quit cleanly:

Private Sub cmdTest_Click()

Dim AppWord As Word.Application

Set AppWord=New Word.Application 'You can use CreateObject() if you wish

MsgBox "Word launched"

AppWord.Quit;
'....................
End Sub

If Word.Application quits correctly here, then find some code in your
project that has something to do with AppWord before cmdExit_Click

"The Roys" <tr*****@hotmail.com> wrote in message
news:oV********************@news-server.bigpond.net.au...
Thanks for your reply, but either way makes no difference. Before exiting, and while program is dormant the process in the Task Manager (Winword.exe) does not take up any CPU usage. But as soon as I run the Exit code the CPU usage goes to 100% and the process is still in the Task Manager.
Every time I run the program a new Winword.exe process begins.

Any ideas ??
"Stephane Richard" <st**************@verizon.net> wrote in message
news:QE******************@nwrdny03.gnilink.net...
> The first thing I see is that you are using a mix of Early and Late
binding
> to create your object.
>
> This is your code as it stands:
> > General Declarations
> > Dim AppWord As Word.Application
> >
> > Form_Load()
> > Set AppWord = CreateObject("Word.Application")
> >
> > cmdExit_Click()
> > AppWord.Quit
> > Set AppWord = Nothing
> > Unload Me
>
> In early binding mode it should be:
> > General Declarations
> > Dim AppWord As Word.Application
> >
> > Form_Load()
> > Set AppWord = New Word.Application
> >
>
> In Late Binding mode (using createobject()) it should be:
> > General Declarations
> > Dim AppWord As Object
> >
> > Form_Load()
> > Set AppWord = CreateObject("Word.Application")
> >
> Try the same code to end your word application object as you have
with one
> of these two declarations (early or late binding). and see if it

still > causes a problem.
>
> --
> Stéphane Richard
>
>
>
> "The Roys" <tr*****@hotmail.com> wrote in message
> news:VK********************@news-server.bigpond.net.au...
> > Hi
> >
> > Im doing something wrong in quitting the Word.Application in my VB
> program.
> > I have
> >
> > General Declarations
> > Dim AppWord As Word.Application
> >
> > Form_Load()
> > Set AppWord = CreateObject("Word.Application")
> >
> > cmdExit_Click()
> > AppWord.Quit
> > Set AppWord = Nothing
> > Unload Me
> >
> > When I click Exit to end my program Winword.exe is still running
as a > > process listed in my Task Manager. Not only is it listed, but the
process
> is
> > taking up 100% of my CPU usage.
> > How do I end the Word.Application correctly ???
> >
> > Thanks
> > Trevor.
> >
> >
>
>



Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Microsoft | last post: by
4 posts views Thread by Darryl Kerkeslager | last post: by
2 posts views Thread by Claus - Arcolutions | last post: by
5 posts views Thread by Filip De Backer | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.