Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Use of Microsoft Word Object

Posted on 2002-05-10
6
Medium Priority
?
154 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
  • 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
Industry Leaders: 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!

 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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 Month20 days, 19 hours left to enroll

810 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