By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,255 Members | 2,773 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,255 IT Pros & Developers. It's quick & easy.

Quitting "Word.Application" Help Please

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.