|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Application.Quit but Word remains open in Task ManagerI have writtwen the following routine, but depsite Word closing it remains open in the Task Manager, and so when AutoExec fires again it will not run befcuase Word is open elsewhere. Is there code that I can use which will truly quite and close Word? Thanks in advance, Simon England. Sub allwingriddsprepare() wingriddsprepare00 wingriddsprepare06 wingriddsprepare12 wingriddsprepare18 Application.Quit End Sub Hi simon,
Is this VB6 code or VBA ? If the later then I doubt you can kill the app as your code is being launched by it. If VB6, where is "Application" defined ? Show quoteHide quote "Simon Keeling" <si***@weatherweb.net> wrote in message news:5c4e15cf-efdb-4548-8039-e8b5217f226e@j35g2000yqh.googlegroups.com... > Hello, > > I have writtwen the following routine, but depsite Word closing it > remains open in the Task Manager, and so when AutoExec fires again it > will not run befcuase Word is open elsewhere. > > Is there code that I can use which will truly quite and close Word? > > Thanks in advance, > Simon > England. > > > Sub allwingriddsprepare() > wingriddsprepare00 > wingriddsprepare06 > wingriddsprepare12 > wingriddsprepare18 > Application.Quit > > End Sub "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message Actually VBA in Office app's can quit itself, both as a project and it's > Is this VB6 code or VBA ? If the later then I doubt you can kill the app > as your code is being launched by it. host application. Of course there might be other objects hanging around that might prevent the close and/or quit. In the case of Word even some open unsaved Outlook mailItem. The OP's code sample is possibly the most unhelpful I have ever seen :-) Regards, Peter T Thanks for that Peter, so it could be something else open? I will have
a look and see what I can find. Soprry about the code, but that is all I have as that is the routing. What else would you have liked to have seen? Thanks, Simon Show quoteHide quote On Mar 16, 11:36 am, "Peter T" <peter_t@discussions> wrote: > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > > > Is this VB6 code or VBA ? If the later then I doubt you can kill the app > > as your code is being launched by it. > > Actually VBA in Office app's can quit itself, both as a project and it's > host application. Of course there might be other objects hanging around that > might prevent the close and/or quit. In the case of Word even some open > unsaved Outlook mailItem. > > The OP's code sample is possibly the most unhelpful I have ever seen :-) > > Regards, > Peter T Apart from the app.quit line your code does not tell us anything at all. Not
even which application it runs in though presumably it's Word VBA in a word document. What's wingriddsprepare00 and the others? some routines, what do they do, what else is going on, etc, etc, and not least where is the code. If indeed it is Word ask in one of the Word groups, eg microsoft.public.word.vba.general (this group is not VBA) However you will need to give some information beyond "my car doesn't work what's wrong". Regards, Peter T "Simon Keeling" <si***@weatherweb.net> wrote in message Thanks for that Peter, so it could be something else open? I will havenews:b8f30bb1-2f87-4f47-903c-c26bbbd221ad@v19g2000yqn.googlegroups.com... a look and see what I can find. Soprry about the code, but that is all I have as that is the routing. What else would you have liked to have seen? Thanks, Simon Show quoteHide quote On Mar 16, 11:36 am, "Peter T" <peter_t@discussions> wrote: > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > > > Is this VB6 code or VBA ? If the later then I doubt you can kill the app > > as your code is being launched by it. > > Actually VBA in Office app's can quit itself, both as a project and it's > host application. Of course there might be other objects hanging around > that > might prevent the close and/or quit. In the case of Word even some open > unsaved Outlook mailItem. > > The OP's code sample is possibly the most unhelpful I have ever seen :-) > > Regards, > Peter T Hi Peter,
"Peter T" <peter_t@discussions> wrote in message Thanks, but if he did that, then no subsequent code would run.news:ee4WjtipJHA.3840@TK2MSFTNGP03.phx.gbl... > > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > >> Is this VB6 code or VBA ? If the later then I doubt you can kill the app >> as your code is being launched by it. > > Actually VBA in Office app's can quit itself, both as a project and it's > host application. BTW: Does Application.Quit kill all instances ? I would presume only the one it is running in. > Of course there might be other objects hanging around that might prevent Yep, this is the most likely cause.> the close and/or quit. In the case of Word even some open unsaved Outlook > mailItem. > > The OP's code sample is possibly the most unhelpful I have ever seen :-) More information is needed, but it does look to me like it was/is VBA, not > VB. Dear all,
Looks like you have solved it for me. I have closed Outlook and run the procedure again. Word closed! Thanks, Simon Show quoteHide quote On Mar 16, 3:19 pm, "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote: > Hi Peter, > > "Peter T" <peter_t@discussions> wrote in message > > news:ee4WjtipJHA.3840@TK2MSFTNGP03.phx.gbl... > > > > > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > > >> Is this VB6 code or VBA ? If the later then I doubt you can kill the app > >> as your code is being launched by it. > > > Actually VBA in Office app's can quit itself, both as a project and it's > > host application. > > Thanks, but if he did that, then no subsequent code would run. > > BTW: Does Application.Quit kill all instances ? I would presume only the one > it is running in. > > > Of course there might be other objects hanging around that might prevent > > the close and/or quit. In the case of Word even some open unsaved Outlook > > mailItem. > > Yep, this is the most likely cause. > > > The OP's code sample is possibly the most unhelpful I have ever seen :-) > > More information is needed, but it does look to me like it was/is VBA, not > VB. Well that was a wild guess earlier, probably not necessary to close Outlook
entirely, just mail items. Strange, I didn't see this your latest post "sent" a while before my other two recent posts. Regards, Peter T "Simon Keeling" <si***@weatherweb.net> wrote in message Looks like you have solved it for me. I have closed Outlook and runnews:96ab0917-c16a-4bc8-959a-fa101d5611cc@v38g2000yqb.googlegroups.com... Dear all, the procedure again. Word closed! Thanks, Simon Show quoteHide quote On Mar 16, 3:19 pm, "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote: > Hi Peter, > > "Peter T" <peter_t@discussions> wrote in message > > news:ee4WjtipJHA.3840@TK2MSFTNGP03.phx.gbl... > > > > > "Bill McCarthy" <TPASoft.com Are Identity Thieves> wrote in message > > >> Is this VB6 code or VBA ? If the later then I doubt you can kill the > >> app > >> as your code is being launched by it. > > > Actually VBA in Office app's can quit itself, both as a project and it's > > host application. > > Thanks, but if he did that, then no subsequent code would run. > > BTW: Does Application.Quit kill all instances ? I would presume only the > one > it is running in. > > > Of course there might be other objects hanging around that might prevent > > the close and/or quit. In the case of Word even some open unsaved > > Outlook > > mailItem. > > Yep, this is the most likely cause. > > > The OP's code sample is possibly the most unhelpful I have ever seen :-) > > More information is needed, but it does look to me like it was/is VBA, not > VB. Hi Bill,
>> Actually VBA in Office app's can quit itself, both as a project and it's Could struggle on for a while, a bit like this in a form>> host application. > > > Thanks, but if he did that, then no subsequent code would run. Private Sub Command1_Click() Unload Me MsgBox "still hanging in there" End Sub Actually I've never quite understood how that works. > BTW: Does Application.Quit kill all instances ? I would presume only the Could do objApp.Quit to kill any referenced instance, subject released > one it is running in. objects, or dialogs appearing (eg the save prompt or some other warning in a hidden instance). 'Application' in VBA only refers to the single instance hosting that code. Regards, Peter T "Peter T" <peter_t@discussions> escribió en el mensaje Because the code module is separate from the form object (I don't understand news:O84%23celpJHA.1172@TK2MSFTNGP05.phx.gbl... > Could struggle on for a while, a bit like this in a form > > Private Sub Command1_Click() > Unload Me > MsgBox "still hanging in there" > End Sub > > Actually I've never quite understood how that works. the details, this is as much - I think.- I undestand). Try this: Start a new project, add another form (Form2) and a command button to each form. ' Form1 code: Private Sub Command1_Click() Form2.pVar = 5 Form2.Show 1 MsgBox Form2.pVar End Sub ' Form2 code: Public pVar As Long Private Sub Command1_Click() Unload Me End Sub You can see that the variable still holds the value after the form is unloaded. To completely erase the form, you need to set it to nothing: ' Modify Form1 code to: Private Sub Command1_Click() Form2.pVar = 5 Form2.Show 1 MsgBox Form2.pVar Set Form2 = Nothing MsgBox Form2.pVar End Sub You also can set the form to nothing from within the form itself, but as it is still executing code, it does it after it is unloaded. ' Modify Form2 code to: Public pVar As Long Private Sub Command1_Click() Unload Me Set Form2 = Nothing MsgBox "from Form2: " & pVar End Sub "Eduardo" <m*@mm.com> wrote in message news:gpnhs4$5bs$1@aioe.org... Yes, my example was not a good one with only the Unload> To completely erase the form, you need to set it to nothing: > You also can set the form to nothing from within the form itself, but as This better illustrates what I meant, the terminate event will not fire > it is still executing code, it does it after it is unloaded. > > ' Modify Form2 code to: > > Public pVar As Long > > Private Sub Command1_Click() > Unload Me > Set Form2 = Nothing > MsgBox "from Form2: " & pVar > End Sub until all code has completed. It is similar with code in VBA that does meProject.Close or Application.Quit. It seems these types of instructions are not executed linearly but put on hold or set aside until all other code completes. In some VBA app's any routine can be called immediately after all other running code completes with the OnTime function, seems like these Set me=nothing, .close & .quit functions work similarly, I guess. Regards, Peter T
Show quote
Hide quote
"Peter T" <peter_t@discussions> wrote in message If you think of the form as a class, the load/unload merely the create and news:O84%23celpJHA.1172@TK2MSFTNGP05.phx.gbl... > Hi Bill, > >>> Actually VBA in Office app's can quit itself, both as a project and it's >>> host application. >> >> >> Thanks, but if he did that, then no subsequent code would run. > > Could struggle on for a while, a bit like this in a form > > Private Sub Command1_Click() > Unload Me > MsgBox "still hanging in there" > End Sub > > Actually I've never quite understood how that works. > destroy windows part there-of. >> BTW: Does Application.Quit kill all instances ? I would presume only the Thanks.>> one it is running in. > > Could do objApp.Quit to kill any referenced instance, subject released > objects, or dialogs appearing (eg the save prompt or some other warning in > a hidden instance). > > 'Application' in VBA only refers to the single instance hosting that code. >
VB App fails when log reaches 65536
HOW IS Memory Used by a VB App vb.net executing on Help with Binary Compatibility Fonts (OT) false positives on my files Internal String Visibility NET Required ??? Can I loop through only SELECTED items in a multi-select FileListBox? Is it possible to remove 3rd party app icon from systray? |
|||||||||||||||||||||||