none
Compile error using DataTable RRS feed

  • Question

  • In the last day 2 days different versions of Word (2003 and now 2010) have thrown the following error when opening documents that have been working fine for years.

    The MS VBA error is: Compile Error - Can't find project or library.

    The code breaks on: Set DataTable = ActiveDocument.Tables(1)

    The next few lines (that don't get executed) are:

    If DataTable.Cell(1, 1) = "" Then
        DataTable.Cell(1, 1) = 1
    End If

    This code is in the AutoOpen sub. It's checking for an existing table with the first cell containing the numeral 1.

    Any help on the problem would be greatly appreciated. Thanks in advance!

    Wednesday, September 12, 2012 9:06 PM

Answers

  • Hi jjfeenix,

    Thanks for posting in the MSDN Forum.

    Based on your issue, I would suggest you add the .Range.Text into a Table cell. Try this code

    If DataTable.Cell(1, 1).Range.Text = "" Then
         DataTable.Cell(1, 1).Range.Text = 1
    End If

    Hope it helps.

    Best Regards,


    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 13, 2012 7:02 AM
    Moderator

All replies

  • Hi jjfeenix,

    Thanks for posting in the MSDN Forum.

    Based on your issue, I would suggest you add the .Range.Text into a Table cell. Try this code

    If DataTable.Cell(1, 1).Range.Text = "" Then
         DataTable.Cell(1, 1).Range.Text = 1
    End If

    Hope it helps.

    Best Regards,


    Leo_Gao [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 13, 2012 7:02 AM
    Moderator
  • Hi jjfeenix

    If I'm understanding your problem correctly, it appears reference(s) to some type libraries have been broken.

    While looking at the code, in the VBA editor, go to Tools/References. Is anything there listed as "MISSING"?

    If this code has been going back and forth between 2003 and 2010 that could have cause the "break" (most likely from 2010 backwards to 2003).


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, September 13, 2012 12:00 PM
    Moderator