|
-
Oct 4th, 2000, 01:14 PM
#1
Thread Starter
Junior Member
I have a vb program that opens a word.basic file and puts in a lot of formatted information. What I would like to do, is allow vb to END and let the user close word when they are finished printing or editing or whatever. OR---in my vb code, know when the user has closed word, then let me close vb.
-
Oct 4th, 2000, 01:21 PM
#2
Addicted Member
After you are finish with the object. set it to nothing.
212 will lead you to the truth
-
Oct 4th, 2000, 01:33 PM
#3
Junior Member
Ciao.........Gary
VB6, SQL Server 7, Access 97
-
Oct 4th, 2000, 01:46 PM
#4
Thread Starter
Junior Member
Nothing stops word
I don't think my problem is clear....
The user controls when Word is done. My vb program cannot close word. I want to close my VB program and leave word running.
-
Oct 4th, 2000, 02:23 PM
#5
Addicted Member
Simply place:
Unload Me
After your last line of the coding that activates Word
212 will lead you to the truth
-
Oct 5th, 2000, 07:01 AM
#6
Thread Starter
Junior Member
Unload ME stops word TOO
Sorry Doc, but Unload ME stops word as well.
My last lines of code are:
MyWord.FilePrintPreview
Unload me
end sub
-
Oct 5th, 2000, 07:38 AM
#7
Fanatic Member
Try using shell to open word, instead of instantiating it. I haven't tried it yet, though
r0ach™
Don't forget to rate the post
-
Oct 5th, 2000, 07:43 AM
#8
Member
How about ShellExecute???
I don't know if you put things in the Word document interactively from VB. If not, why not use ShellExecute to lauch Word with the right file?
Greets,
-
Oct 5th, 2000, 09:00 AM
#9
Thread Starter
Junior Member
VB is building the Word document
In my application, I am reading a text file and selectively putting information into the word document from VB, so SHELL won't work for me.
-
Oct 5th, 2000, 02:09 PM
#10
Member
Edit and shell?
How about first using Word through CreateObject.
Modify the document with your data from the text file
and then save it. This all can be done without Word being
visible, so the user can not interupt this process. After
saving the file, close Word (the CreateObject version) and
use ShellExecute to launch Word/the file so it will exist
after your application is closed.
Hope this helps you.
Greetings,
-
Oct 5th, 2000, 03:11 PM
#11
Addicted Member
I wrote the following in my vb application to test whether the user has closed an application (Word, Excel, Pbrush, etc.). It has worked well so far. I hope it may help.(Reply to the latter part of your post.)
Put it in a module. (I copied it directly from my app.)
Code:
-------------------------------------------
Private Declare Function GetWindow Lib "user32" (ByVal _
hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () _
As Long
Private Declare Function GetWindowText Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString _
As String, ByVal cch As Long) As Long
Private Const GW_HWNDFIRST = 0
Private Const GW_HWNDLAST = 1
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDPREV = 3
Private Const GW_OWNER = 4
Private Const GW_CHILD = 5
Public Function CheckApp(ByVal AppCaption As String) As Long
'
'--------------------------------------------------------------
' Check whether an application has been closed.
' Return:0 = Not Closed; 1 = Closed
¡® It¡¯s better to use the VB keyword Like in the IF statement.
¡® AppCaption is the first few characters of the name of a window, whether shown or hidden.
'--------------------------------------------------------------
Dim lngHwnd As Long
Dim strWinText As String
Dim lngCch As Long
Dim lngReturn As Long
lngHwnd = GetDesktopWindow()
lngHwnd = GetWindow(lngHwnd, GW_CHILD)
Do
lngCch = 255
strWinText = String(255, 0)
lngReturn = GetWindowText(lngHwnd, strWinText, lngCch)
strWinText = Left(strWinText, lngReturn)
If Left(strWinText, Len(AppCaption)) = AppCaption Then
CheckApp = 0
Exit Do
End If
CheckApp = 1
lngHwnd = GetWindow(lngHwnd, GW_HWNDNEXT)
Loop Until lngHwnd = 0
End Function
-----------------------------------------
Visual Basic Professional 6.0
-
Oct 10th, 2000, 07:27 AM
#12
Thread Starter
Junior Member
IT works - Thanks XMIN
Sorry for the slow response, but I was out of the office. Got this information from XMIN and put it into my program and it is working great. Thanks for all of the help!! Mr_Ed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|