Why does sub-routine now fail with Compile error: User-defined type not defined

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WECcoder

    #1

    Why does sub-routine now fail with Compile error: User-defined type not defined

    This code used to work prior to our group IT update to Word
    I thought Word.Applicatio n was a generic type defined to Access?

    Code:
    Private Sub cmdDatasheetsDigital_Click()
    Set db = CurrentDb
    Dim Wrd As New Word.Application  < Fails Here
    Dim Doc As Word.Document
    Dim otable As Word.table
    Dim oldstring As String
    Dim newstring As String
    Dim FirstPass As Integer
    Dim strProject As String
    Last edited by MMcCarthy; Oct 20 '10, 09:18 PM. Reason: Added Code Tags
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    VBA does not include the code libraries for the other Office applications unless you set an explicit reference to the library concerned. The reference to the Word library appears to be missing at present.

    From the VB editor select Tools, References and look for a missing reference to the Microsoft Word object library (if it was OK before the upgrade you mention). If you don't see a missing reference then scroll the list down to the Microsoft Word 11.0 or 12.0 library and tick that entry to include the Word object library in your project.

    Please note that the Word 12.0 library is the one from Office 2007; Word 11.0 refers to Office 2003. An upgrade can play havoc with references if you are working in a mixed Office 2003/2007 or later environment.

    -Stewart

    Comment

    Working...