|
-
Aug 19th, 2000, 08:07 AM
#1
Thread Starter
New Member
I have built an application and tried to launch Word using:
_________________________________
Public Sub Send_Word()
Dim hWord As Long
Dim Appword As Word.Application
Dim refstr As String
On Error Resume Next
'I have declared previously this function
hWord = FindWindow("OpusApp", 0& )
If hWord = 0 Then
Set Appword = CreateObject("Word.Application")
End If
With Appword
If .Documents.Count = 0 Then
.Documents.Add
End If
End With
referstr = txtAuthors.Text
Appword.Documents(1).Range.InsertAfter referstr & _
vbCrLf
Appword.Visible = True
End Sub
________________________________________________
While it works fine in my computer (Win 98, Word 2000), it does not work in other computers (e.g. Win 95, Word 97)where the application was installed.
I have put a reference to "Microsoft Word 9.0 Object Library".
Is it possible that there is a problem with this library or what else?
Please Help.
THANKS in advance
emmzou
-
Aug 19th, 2000, 08:17 AM
#2
Monday Morning Lunatic
It's an incompatibility between the different versions. Office 9 (2000) is different to Office 8 (97), so they will have a different type library. If you use
Code:
Dim wd as Object
Set wd = CreateObject("Word.Application")
and use the wd object, this might help.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 19th, 2000, 02:12 PM
#3
Thread Starter
New Member
Thanks parksie
Do you mean that using this I do not have to refer to the "Microsoft Word 9.0 object Library" ?
THANKS again
-
Aug 19th, 2000, 09:56 PM
#4
It might be handy but remember that late bindings means a performance hit. It could be considered handy to use Variant variables all over the code as well.
-
Aug 20th, 2000, 05:02 AM
#5
Monday Morning Lunatic
Perhaps. It just depends on whether you can guarantee the version on the end-user's machine.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 07:56 AM
#6
Thread Starter
New Member
Unfortunately dear Parksie this eventually did not work.
I declared the variable as object and I removed the reference to Microsoft Word 9.0
However, again I cannot start the Word and add documents when the application is installed (usind the integrated packaging wizard) in other computers with previous version of Office or Windows.
Any other idea,
THANKS a lot anyway
emmzou
-
Aug 21st, 2000, 01:26 PM
#7
Monday Morning Lunatic
It worked on mine. Starting a plain project, and adding this code:
Code:
Dim z As Object
Private Sub Form_Load()
Set z = CreateObject("Word.Application")
'z.newdocument
End Sub
Private Sub Form_Unload(Cancel As Integer)
z.quit
Set z = Nothing
End Sub
When I ran it, my task list showed that Word had been loaded. When I closed the form, Word disappeared. It obviously loaded, then.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 21st, 2000, 06:57 PM
#8
Try to declare the Appword object outside of the Sub. I don't know about Win9x but on both of my development mashines (were I use WinNT and Win2000) the Word application closes as soon as the object lose it's scope.
That is at the end of your sub.
-
Aug 21st, 2000, 07:00 PM
#9
Monday Morning Lunatic
Hm. That must have been why mine worked. Does VB clean up dynamic objects, then? I'm too used to C++ giving you a bazooka to blow your foot off with .
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
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
|