Macro to Check for Multiple Instances of WordLast reviewed: July 30, 1997Article ID: Q109836 |
The information in this article applies to:
SYMPTOMSYou start Word when another instance of Word is already running, but you get no message to that effect.
CAUSEIn Microsoft Windows, if a share program such as SHARE.EXE, VSHARE.386, or any other share utility is in use, multiple instances of the same program can be run at the same time. You cannot configure Word to prevent this from occurring.
RESOLUTIONThe follow macro, when named AUTOEXEC, will check to see if any other instances of Word are running and if so, will then give you the option of closing one instance or allowing a new instance. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
size = AppCount() - 1
Dim winnames$(size)
AppGetNames winnames$()
For i = 0 To size
If InStr(1, winnames$(i), "Microsoft Word") Then
count = count + 1
ListBox1$(count - 1) = winnames$(i)
End If
If count > 1 Then
Begin Dialog UserDialog 322, 174, "Microsoft Word"
OKButton 222, 121, 88, 21
CancelButton 222, 147, 88, 21
ListBox 10, 70, 300, 45, ListBox1$(), .ListBox1
Text 10, 6, 300, 60, text$, .Text1
End Dialog
Dim dlg As UserDialog
If Dialog(dlg) = - 1 Then
AppClose(ListBox1$(dlg.ListBox1))
End If
i = size
End If
Next
bye: '<-- This line MUST be left aligned
End Sub
NOTE: In the macro above, the continuation character "\" is not necessary
if the text is typed without a carriage return at the end of the line.
Kbcategory: kbusage kbmacro KBSubcategory: |
Additional query words: 6.0 6.0a 6.0c 7.0 word95 copies copy two
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |