Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Unanswered: Access and Word Automation

    Hello all. Ok, I ran into the code above and I think it's what I need. I'm not sure how I would modify it to work on my form. Here's my scenario:

    tblTransactions
    TransactionsID - Autonumber
    ClientFirstName - Text
    ClientLastName - Text

    frmDocuments
    txtClientNo - Number
    cmdProcess - When clicked, Access displays documents in lbxDocuments corresponding to client number entered in txtClientNo text box.
    lbxDocuments - This list box displays the documents that are available to the user. The user opens the document by double clicking on the document in the list.

    All of the above works perfectly! I just need to know how to incorporate the above code so that when the user double clicks on the document in the list box, the document will open, connect to table, and merge data from record # entered in txtClientNo. Would the process be different if I was doing this from a list box with multiple documents?

    Hope this all makes sense. I would love your assistance!

  2. #2
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Ummmm....what code?

    Sam
    Good, fast, cheap...Pick 2.

  3. #3
    Join Date
    Oct 2009
    Posts
    2

    Code

    Sorry, here's the code I found online. How can I incorporate into my project?

    Code:
    Private Sub cmdBlurbRequest_Click()
    
    Dim rsData as DAO.Recordset
    Dim strSQL as String
    
    strSQL = "Select * from Junction Where Primary Key = " & Me.txtFileNo
    
    set rsData = CurrentDB.OpenRecordSet(strSQL)
    
    'Launch word and load the template
    Dim objWord As Word.Application
    Set objWord = CreateObject("Word.Application")
    objWord.Documents.Add Application.CurrentProject.Path & "\BlurbRequest.dot"
    objWord.Visible = True
    
    'Add information to the template
    'With objWord.ActiveDocument
    '.Unprotect
    
    .FormFields("PE").Result = rsData!PE
    '.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
    
    rsData.Close
    set rsData = Nothing
    
    End With
    
    'Exit Word
    'objWord.Quit
    'End Sub

Posting Permissions

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