Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    DataObject Compile Error (MSWord 2003)

    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:= _
    "Cocuments 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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DataObject Compile Error (MSWord 2003)

    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.

  3. #3
    Star Lounger
    Join Date
    Jun 2002
    Location
    Johannesburg, Gauteng, South Africa
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Re: DataObject Compile Error (MSWord 2003)

    Hans,

    What can I say - you are a star <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •