?
Solved

Use of Microsoft Word Object

Posted on 2002-05-10
6
Medium Priority
?
147 Views
Last Modified: 2010-05-02
I have integrated Microsoft Word into my application and it is used to open a template, do various things to the template and then save it. It is also used to open a new document based on the template and then save that after reformatting, etc. This all works fine but only, it seems when Word 2000 is being used. It fails with '95 and '97. The object library I am using is the MSWORD9.OLB. I presume that for some reason this isn't compatible with earlier versions. I can probably live with this if I have to, but will I have the same problem with later versions of Word too? If it is possible to overcome this problem I would be grateful for advice., e.g., is is ppossible to use an earlier object library to ensure compitibility, and if so any ideas where I can find it? Thanks

As there are about 4 different questions here the points will reflect this. Thanks again.

Colin.
 
0
Comment
Question by:cbitservices
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 800 total points
ID: 7001887
If you use CreateObject("word.application") everything would works fine.
Do your development with a type library. When finish, remove it and use generic object variables for all word objects.
Doing so, while development, you have autolist members and others benefits.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7001894
VB would take cares of create that word instance.
if you are using, for instance:
dim wdapp as new word.application
it sticks with your refernced library (8, 9 or 10)
but if you use
dim wdapp as bject
set wdapp=createObject("word.application")
is vb which will create correct object accoding to end user office installation.
Hope i was clear
PS: i don't know regarding Office95, sorry.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7001898
Also, take in mind that there are some funcionality that you could get with newer version but not with old one. different implementations for same matter could be an issue between version.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:roverm
ID: 7001957
Richie is correct, the best way to get a reference to word is using late binding. This way you never have to worry about versions.

When you develop your application you might use early binding by setting a reference to the OLB, so you have IntelliSense.

Here what I usually do to get any object (like word):

Public bNewWord As Boolean
Public oWord As Object

Public Function GetInstance() As Boolean

    'try to get a reference to an existing open instance of Word
    On Error Resume Next
    bNewWord = False
    Set oWord = GetObject("", "Word.Application")
    If Err.Number <> 0 Then
        'there was an error ==> no Word instance was opened yet, create it
        bNewWord = True
        Err.Clear
        Set oWord = CreateObject("Word.Application")
    End If
    oWord.Visible = True
    GetInstance = Not (oWord Is Nothing)
   
End Function

Public Function DestroyInstance() As Boolean

    'if we opened a new instance then quit Word
    If bNewWord Then oWord.Quit
    'destroy handle to it and free memory
    Set oWord = Nothing
   
End Function

D'Mzzl!
RoverM
0
 
LVL 1

Author Comment

by:cbitservices
ID: 7002244
Thanks Richie,

I knew there was probably a simple answer; I just didn't know what it was! I know now though thanks to you! Thanks for a speedy response too!

Cheers,

Colin.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7002299
Thanks to you for "A" grade.
Glad to help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question