Results 1 to 9 of 9

Thread: Starting Word...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    14

    Question

    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


  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    14
    Thanks parksie

    Do you mean that using this I do not have to refer to the "Microsoft Word 9.0 object Library" ?

    THANKS again

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    14
    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

  7. #7
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width