Results 1 to 4 of 4

Thread: Word Automation Problems

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2000
    Location
    Glasgow, Scotland
    Posts
    71

    Word Automation Problems

    Hi,

    I have an application that using word automation to create a word document. I have referenced the word 8.0 object library and the application works fine on a machine with office 97 installed.

    However I have installed the application on a machine with office 2000 and XP and it does not work. Does anyone know how I can configure my application to work with all version of word.

    Note: I am not doing anything complicated with the word document and all feature should be availble in all version of word.

    Thanks for your help,

    Chris

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    remove the reference and try this:
    VB Code:
    1. Option Explicit
    2.  
    3. Public objWord As Object 'instead of Word.Application
    4. Public wd As Object  'instead of Word.Document
    5.  
    6. Private Sub Command1_Click()
    7.  
    8.     If objWord Is Nothing Then
    9.         Set objWord = CreateObject("Word.Application")
    10.     Else
    11.         Set objWord = GetObject(, "Word.Application")
    12.     End If
    13.     DoEvents
    14.     Set wd = objWord.Documents.Open("c:\Test.doc")
    15.     'here u can do stuff with the document
    16.     'using the wd object
    17.        
    18.     'adding some text to it
    19.     wd.ActiveWindow.Selection.TypeText "ABCDEFGH peet was here ! :-)"
    20.    
    21.     'when finished manipulating the document, u can show it To the user
    22.     objWord.Visible = True
    23.  
    24.     'quit word
    25.     If Not (wd Is Nothing) Then Set wd = Nothing
    26.     If Not (objWord Is Nothing) Then objWord.Application.Quit
    27.     If Not (objWord Is Nothing) Then Set objWord = Nothing
    28. End Sub
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by robbedaya
    remove the reference and try this:
    VB Code:
    1. .....
    2.        
    3.     'adding some text to it
    4.     wd.ActiveWindow.Selection.TypeText "ABCDEFGH peet was here ! :-)"
    5. ...
    wow.. I was there ! :-D
    -= a peet post =-

  4. #4
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    yep, i saw this tread and i knew i saw a post of you in another thread that was usefull. And because it wos your code, i didn't remove your name.
    - Use the thread tools to Mark your Thread as Resolved when your question is answered.
    - Please Rate my answers if they where helpful.

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