Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Use of Microsoft Word Object

Posted on 2002-05-10
6
Medium Priority
?
150 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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