473,385 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Waiting for another app to close

Hi there,

I've got some code to open up an Excel workbook but what I want is for the
code to pause until the Excel workbook is closed.

Sub EditWorkbook(strFile as String)

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim strPath As String
Dim fClosed As Boolean

Set xlApp = New Excel.Application

strPath = "C:\My Documents\" & strFile

Set xlWorkBook = xlApp.Workbooks.Open(strPath)
xlApp.Visible = True

Do Until fClosed = True
If fIsAppRunning("Excel") = False Then
fClosed = True
End If
Loop
MsgBox "Finished"

End Sub

The fIsAppRunning function is from
http://www.mvps.org/access/api/api0007.htm
The workbook opens up OK for editing but when Excel is closed the code
continues to loop through the Do Until Loop statement.
When I type EditWorkbook in the immediate window and then close down Excel,
focus doesn't come back to Access directly until I go Ctrl + Break. When
stepping through the code after that I find out that the fIsAppRunning
function still says that Excel is still running although it's not visible
any more. Going Ctrl + Alt + Del to view what programs are still running, I
see Excel is still in the list. When I click cancel for this close program
list, click the End button and then view the list of open programs again,
Excel is no longer in the list.

I've tried using the ShellAndWait sub routine and also the sSleep sub
routine from the same site.

What is the best way to do this? Does someone have a solution to why Excel
is still running in the background and won't close correctly even when the X
is clicked in Excel.

Stewart



Nov 12 '05 #1
0 1349

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: MikeE | last post by:
Hi all, What's the best way to queue up and wait for number of threads to complete. This problem was trivial in VC++ 6 but I'm finding it rather hard to solve in VB.NET. My calculations run...
2
by: Dicky Cheng | last post by:
Hi, I am using .net remoting technology. I set up a .net remoting client and server in IIS. When the client calls the server, the server will run a long duration method (30-60seconds). I have a...
39
by: jabailo | last post by:
I am looping through a text file, and with each row, I launch a web service, asynchronously. Before I move on to the next step in the process, I want to make sure that all the web services have...
5
by: bughunter | last post by:
Hi, Consider this code: ---- Monitor.Pulse(oLock); Monitor.Exit(oLock); ---- If a thread was waiting on oLock then will the current thread
5
by: Ken Kast | last post by:
I have the following app logic: 1. A form frmMain shows another modeless form. The second form is stored in a private variable ScrnTip in frmMain. A system timer is set to close the form. 2....
12
by: Raymond Lewallen | last post by:
How to wait for a process to stop completion is my goal. Obviously, the looping while waiting for the HasExited property is not a solution.. but thats the best I can come up off the top of my...
16
by: Bruce Wood | last post by:
Maybe it's just late in my day, but I'm reading Jon's article on threading, in particular how to use Monitor.Wait() and Monitor.Pulse(), and there's something that's not sinking in. The code in...
2
by: Bob | last post by:
I launch Word from within my application (Vs2005, VB) and I would like to make it necessary for the just opened Word to be closed before the rest of my code in the calling sub can execute. How can...
4
by: Jono | last post by:
Hi Everyone, As it says in the title, I'm looking for a way to display a page while long running operations are performed on the server. Ideally, I'd like some way to push the current request...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.