Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Word Object Library question

Posted on 2002-05-24
8
Medium Priority
?
219 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
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!

 
LVL 18

Accepted Solution

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

Dim aThisDoc As Word.Document
Dim range1 As Word.Range
0
 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

876 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