Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

issue with ADP and word doc

issue with ADP and word doc

issue with ADP and word doc

i had the following code working okay in an .MDB but i have now moved this to an .ADP and i cannot figure out the following error. i get  "user defined type not defined"

'Open Word, import the text to the bookmarks and display the letter
    Set objWord = New Word.Application
    objWord.Visible = False 'was True
    'Open Your Recordset and move to the first record
    Set Db = CurrentDb
    Set rs = Db.OpenRecordset("Invitations_ToGo", dbOpenDynaset)
    'Loop through each record of the Rs, inserting each field of the record into a Bookmark in the template
    Do Until rs.EOF
     Set objWordDoc = objWord.Documents.Add(Template:="C:\DM_Inputs\Invite.dot", NewTemplate:=False)
    With objWordDoc
     .Activate  '<------- important
     .Bookmarks("InviteInfo").Range.Text = rs![First Name] & " " & rs![Last Name] & vbCrLf & rs![Address 1] & "  " & rs![Address 2] & vbCrLf & rs!City & ", " & rs!State & "  " & rs!Zipcode & vbCrLf & vbCrLf & vbCrLf & rs!Datesent & vbCrLf & vbCrLf
    End With
        'Save the letter to the desired folder
     Dim strhdr1 As String
         strhdr1 = rs![Last Name] & "_" & rs![First Name]
     objWordDoc.SaveAs filename:="c:\DM_Outputs\Invitation_" & strhdr1 & ".doc"
     Set objWordDoc = Nothing
Set objWord = Nothing

thanks for any advice

RE: issue with ADP and word doc

My hunch is converting to an ADP stripped your reference to Word.

RE: issue with ADP and word doc

thanks lameid that was correct, i keep forgetting to recheck those settings, after adding that back in it still errors out trying to set the recordset, is there any good documentation for .ADP? i am so use to using vba coding within the database but i am finding more and more that .ADP just will not accept.

RE: issue with ADP and word doc

Is your ADP using ADO (default) or DAO? You can have both if you want.

Your recordset is using DAO syntax and you might have to either change that to ADO or set the reference to DAO also.

What exactly is the error line?

Apart from this type of problem and minor syntax like removing rs.edit statements, you should not have any major issues with an ADP.

RE: issue with ADP and word doc

To expand on what payback wrote, you could add the DAO reference (assuming it is missing) and preface your DAO declarations with the library.  For example...

Dim DB as DAO.DB
Dim RS as DAO.Recordset

Keep in mind too that the changes to switch to ADO are minimal and Microsoft's prefered way of using recordsets.

Alternatively making the DAO library come before the ADO library would work too but then you would have to preface ADO declarations (ADODB if memory serves).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close