Solved

Word Object Library question

Posted on 2002-05-24
8
208 Views
Last Modified: 2010-05-02
I have a VB app that pushes some text into a Word doc and prints it. This works just fine under XP with a reference to "Microsoft Word 10.0 Object Library" but when I run it on another machine with Win98 and change the reference to "Microsoft Word 9.0 Object Library" it won't recognize the Word object.

So, as I see it, I have three choices

1) Figure out where the Word 10.0 thing is on the XP machine and copy it over to the 98 machine --- does anyone know, first where to find the Word 10.0 Object Library file (DLL or whatever it is), and second is it likely to work under Win98?

2) Figure out why the Word 9.0 library doesn't recognize the word object --- I haven't a clue how to do this; it seems that it should work as is.

3) Find Bill Gates and hurt him.

Since #3 doesn't seem likely, any help with #1 or #2 will be appreciated.

Thanks for your time.

Paul

0
Comment
Question by:HobbitHouse
  • 4
  • 3
8 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7032485
don't use early binding... use late binding.

ie:

Dim wdApp as Word.Application

set wdApp = CreateObject("Word.Application")

then it won't matter won't version of word you have on your computer.
0
 

Author Comment

by:HobbitHouse
ID: 7032709
no joy.

the bad news is that I was running a canned set of code that I was given and it works fine on the XP machine, but I don't fully follow the details of what it's doing, so I'm likely missing something else.  I've attempted to condense the problem as it now stands into one module for your inspection.  Here it is, using your suggestion and showing the error message line


'
' set_up_Word --- instantiate MS Word and set up landscape doc using
'                 Courier New font
'
Public Sub set_up_Word()
    Dim wdApp As Word.Application
    Dim strWorkingDocName As String
    Dim aThisDoc As Document
    Dim range1 As Range

    Set wdApp = CreateObject("Word.Application")
    wdApp.Documents.Add
    strWorkingDocName = wdApp.ActiveDocument.Name
    Set aThisDoc = wdApp.Documents(strWorkingDocName)
'
' the next line gives a compile error saying "method or data member not found"
'
    aThisDoc.PageSetup.Orientation = wdOrientLandscape
    Set range1 = aThisDoc.Range
    range1.Font.Name = "Courier New"
    range1.InsertAfter str
End Sub
0
 

Author Comment

by:HobbitHouse
ID: 7032715
str is a global document string
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
ID: 7032719
just to be sure, do:

Dim aThisDoc As Word.Document
Dim range1 As Word.Range
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 44

Expert Comment

by:bruintje
ID: 7032721
Hi HobbitHouse,

Try

Public Sub set_up_Word()
   Dim wdApp As Object
   Dim strWorkingDocName As String
   Dim aThisDoc As Document
   Dim range1 As Range

   Set wdApp = CreateObject("Word.Application")
   wdApp.Documents.Add
   strWorkingDocName = wdApp.ActiveDocument.Name
   Set aThisDoc = wdApp.Documents(strWorkingDocName)
'
' the next line gives a compile error saying "method or data member not found"
'
   aThisDoc.PageSetup.Orientation = wdOrientLandscape
   Set range1 = aThisDoc.Range
   range1.Font.Name = "Courier New"
   range1.InsertAfter str
End Sub

:O)Bruintje
0
 

Author Comment

by:HobbitHouse
ID: 7033039
that did the trick.  many thanks.

0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7033048
glad you got it! :)
0
 

Author Comment

by:HobbitHouse
ID: 7033138
bruntjie, thanks for your time as well
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now