• DataObject Compile Error (MSWord 2003)

    Author
    Topic
    #443629

    Hi,
    I run the code detailed below on my PC under Windows 2000 with no problem.

    I have tried to run it on two other users macines (running XP Professional) and keep getting an error – “Compile error: User-defined type not defined”. I thought that DataObject was a VBA type (search of the VBA help seems to confirm this) not a user type. Any suggestions?

    Code follows:

    Sub BranchMailCountsNew()

    ‘ BranchMailCountsNew Macro
    ‘ Macro recorded 09/09/2002 by Raymond Anthony Basson

    Documents.Add Template:= _
    “C:Documents and SettingsAdministratorMy DocumentsTemplatesWordBRANCH MAIL COUNTS .dot”, _
    NewTemplate:=False, DocumentType:=0
    Selection.Paste
    Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=””
    Selection.SelectRow
    Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
    Selection.Rows.HeadingFormat = wdToggle
    Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=1, Name:=””
    Selection.MoveRight Unit:=wdCell
    Selection.MoveLeft Unit:=wdCell
    Selection.Copy
    With ActiveDocument.Bookmarks
    .Add Range:=Selection.Range, Name:=”SaveName”
    .DefaultSorting = wdSortByName
    .ShowHidden = False
    End With
    Dim MyData As DataObject THE ERROR HAPPENS HERE
    ] Set MyData = New DataObject

    Any help would, as usual, be greatly appeciated

    Viewing 0 reply threads
    Author
    Replies
    • #1070508

      DataObject belongs to the MSForms library. Do the following in the Visual Basic Editor:
      – Select Insert | UserForm
      – If necessary, expand the Forms node in the Project Explorer on the left hand side.
      – Right-click the userform (probably named UserForm1).
      – Select Remove UserForm1… from the popup menu.
      – Answer No to the question whether you want to export the form before removing it.
      – You should now have a reference to the Microsoft Forms 2.0 Object Library, and DataObject should be recognized.

    Viewing 0 reply threads
    Reply To: DataObject Compile Error (MSWord 2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: