Results 1 to 3 of 3

Thread: Access with word

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Access with word

    I have a word document with bookmarks. I also have a database in access with a form. On the form is a button, when the user clicks on the button, i want to open the specific word document, transfer all the information from the text boxes to the relevant bookmarks and then print it off.

    I do not know how to link the textboxes to the bookmarks and how to point to the word document. can someone help?

    As for the printing auto i think its a macro created for as soon as the word document opens-am i right or will it print document before the transfer has happened?

  2. #2
    Addicted Member
    Join Date
    Jun 2002
    Location
    Brugge, Belgium
    Posts
    208
    VB Code:
    1. Function PrintDocument(Klant As Long, opdracht As Long)
    2. Dim str As String
    3. Dim doc As Object
    4. Dim textdoc As Object
    5. Dim wrdrange As Object
    6. Dim adors As ADODB.Recordset
    7. Dim naam As String
    8. Dim vnaam As String
    9. Set wd = CreateObject("Word.Application")
    10. wd.Visible = False
    11. Set doc = wd.Documents.Add("c:/program files/vbase/data/documents/dagboek.dot")
    12.  
    13. Set adors = New ADODB.Recordset
    14. With adors
    15. .Open "select naam, voornaam from klant where id=" & Klant, adocn, adOpenDynamic, adLockOptimistic
    16.     If Not .EOF And Not .BOF Then
    17.         doc.FormFields("Firstname").Range = " " & !voornaam
    18.         doc.FormFields("Lastname").Range = " " & !naam
    19.     End If
    20. .Close
    21. End With
    22. Set adors = Nothing

    this should help you on the way. BTW I'm using late binding as one can get into problems with different versions of word.

    I used to do this a lot in Word and VB but now I rather use xl as the manipulation is easier.

    greetz,

    Jason

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    See this doesn't make sense.

    In your function, you've said klant as long-is this meant to mean the table?

    See the thing is all the information i'm getting is from three linked tables.

    A mixture of everything is loaded onto a form, and from then i want to copy them to the relevant bookmarks in word.

    The code you showed only shows for one table. Thing is how do you say textbox1 = relevant bookmark?

    My tables are as follows if this will assist you in helping me.

    Invoice(Invoice no, date, company no, nett total, vat total, final total)

    Description(Description No, description,net value, vat value, total, invoice no)

    Sales Address(company no, company name,address)

    On my form i have all of these only once.

    Can you help me out please?

Posting Permissions

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



Click Here to Expand Forum to Full Width