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 I do this?
Thanks for any help
Bob 2 1777
Hello, Bob,
This isn't "elegant", but seems to work:
Imports System.Threadin g.Thread
Imports System.Runtime. InteropServices
Public Class Form1
Inherits System.Windows. Forms.Form
. . .
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button1.Click
Dim appWord As New Word.Applicatio n
appWord.Visible = True
MsgBox("Waiting for Word to close...")
Do
Try
' Examine some (any) property of Word application.
Dim booTest As Boolean = appWord.Visible
Sleep(100)
Catch ex As COMException
If (ex.ErrorCode = &H80010108) Then
' object has disconnected from its clients.
MsgBox("Continu ing...")
Exit Do
Else
' Unexpected error.
Throw New Exception(ex.Me ssage, ex)
End If
Catch ex As Exception
' Unexpected error.
Throw New Exception(ex.Me ssage, ex)
End Try
Loop
End Sub
End Class
Cheers,
Randy
Bob wrote:
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 I do this?
Thanks for any help
Bob
Hello again, Bob,
I've just seen your later post, and (if your staring Word as a process
rather than as an application) Cor's answer there is much better . That is:
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button1.Click
Dim procWord As Process = Process.Start(" Mydoc.doc")
MsgBox("Waiting for Word to close...")
procWord.WaitFo rExit()
MsgBox("Continu ing...")
End Sub
Cheers,
Randy
R. MacDonald wrote:
Hello, Bob,
This isn't "elegant", but seems to work:
Imports System.Threadin g.Thread
Imports System.Runtime. InteropServices
Public Class Form1
Inherits System.Windows. Forms.Form
. . .
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles Button1.Click
Dim appWord As New Word.Applicatio n
appWord.Visible = True
MsgBox("Waiting for Word to close...")
Do
Try
' Examine some (any) property of Word application.
Dim booTest As Boolean = appWord.Visible
Sleep(100)
Catch ex As COMException
If (ex.ErrorCode = &H80010108) Then
' object has disconnected from its clients.
MsgBox("Continu ing...")
Exit Do
Else
' Unexpected error.
Throw New Exception(ex.Me ssage, ex)
End If
Catch ex As Exception
' Unexpected error.
Throw New Exception(ex.Me ssage, ex)
End Try
Loop
End Sub
End Class
Cheers,
Randy
Bob wrote:
>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 I do this?
Thanks for any help Bob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joseph Suprenant |
last post by:
Hello all,
I have a C++ program, it does some calculations on things and then
prints out a file in the format in which GNUPLOT can use. So my question is
how would i call GNUPLOT from my C++ program. I know in some operating
systems you can do system("gnuplot"); But not with red hat 7.3. So could
some kind soul help me out? After it starts up GNUPLOT my program will
terminate.
Thanks
|
by: Ted |
last post by:
In doing a db2 list applications show detail, I have 320 entries
applications. Of those sometimes all of them are "UOW Waiting."
Ususally there are from 1 to 4 marked UOW Executing. The rest are
still waiting.
What is meant by "waiting"? We have set TCPCOMMMGR to 4 (16 CPUs). We
have increased IOCLEANERS and IOSERVERS, which had been set to low.
Still the "waiting".
Thanks in advance,
|
by: Charles Law |
last post by:
Consider the following scenario:
A data packet is sent out of a serial port and a return packet is expected a
short time later.
The application sending the packet needs to send another packet as soon as
the return packet has been received. It needs to wait for the return packet,
but time out if one is not received.
Whilst packets are being exchanged the application needs to be responsive.
|
by: Mr Dyl |
last post by:
I'm using Boost to run a couple of threads, one of which reads commands
via std::cin and another receives them through a socket. It's entirely
possible that during the life of the app, all commands will be sent
through the socket and the thread watching cin will never "see any
action". So the problem is, how do I terminate this thread that waits
for keyboard input?
Unfortunately, Boost::thread doesn't yet allow me to force the thread...
|
by: Hugh Janus |
last post by:
Hi group,
I am executing a shell command that calls a .BAT file. I have to wait
for this batch file to finish so I use the wait = true parameter in the
shell command. However, this means that my app freezes causing the
form is not be refreshed when something goes in front of it and then
disappears. This looks ugly and gives the impression that the program
has crashed.
Any ideas how I can repaint my screen whilst waiting for the...
| |
by: Daz |
last post by:
Hi everyone,
Sorry about the long thread name, I think that my problem is that I
don't know how to word it, which is why I have been unsuccessful
finding the information I require.
I am trying to execute an html document (to open in the default
browser), but as a result, my program waits for the document to be
closed before my program will terminate. What I need to find is a way
to run a third party app, and for my program to stop...
|
by: norm4h8 |
last post by:
Hi!
I have a question about how to create a process in such a way that it
would terminate itself if its wated for input for too long.
Here is the story. I have 2 different files, say R.c and S.c, which
have a named pipe between them and send each other signals. R process
starts first, it opens a named pipe and waits for S to connect. S
connects to the pipe, writes something to it and sends the signal to R
indicating that R can read....
|
by: cnoobie |
last post by:
Problem 1 - Min, Mean, Max
Write a program that reads in successive integer values from the user. The user will indicate termination of these values with the sentinel value 0 (zero). After the program has read in the values, the program will output the minimum value entered, the maximum value entered, and the mean (average) of the values entered (to two decimal places). If the user does not enter any numbers before entering 0, the program...
|
by: Tyler |
last post by:
Hello All:
I am currently working on a project to create an FEM model for school.
I was thinking about using wxPython to gather the 12 input variables
from the user, then, after pressing the "Run" button, the GUI would
close, and the 12 input variables would then be available for the rest
of the program.
So far, what I have been able to do is mostly a reverse engineering
job to get the frame to look right and return the text variable...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |