Results 1 to 4 of 4
  1. #1
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51

    Use VBA to copy table contents to the clipboard?

    I have a 2003 Access database with a table containing one number field and one text field and would like to be able to copy all records in that table into the clipboard ready for pasting into email or Word. When you copy and paste table contents manually you get the table outline and headings which is what I want. How can you do it with VBA though?



    Thanks in advance

  2. #2
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    This might help with what you are trying to do:

    Export Access Data with VBA

  3. #3
    Deutz is offline Advanced Beginner
    Windows Vista Access 2010 (version 14.0)
    Join Date
    Oct 2010
    Posts
    51

    Lining up the text in Word

    Thanks for that link. The code exports the fields to Word as required but I am having trouble lining up the text as not all rows tab evenly in Word for some reason.

    Any suggestions would be appreciated.

    Here is my code:

    Set db = CurrentDb()
    Set rs = db.OpenRecordset("tblResult")
    Set fld1 = rs.Fields(0)
    Set fld2 = rs.Fields(1)

    WordEx
    sel.TypeText Text:="DIN: " & vbTab & vbTab & "Letter Name: " & vbCrLf
    sel.TypeText Text:="==== " & vbTab & vbTab & "========= " & vbCrLf
    Do Until rs.EOF
    sel.TypeText Text:=fld1.Value & vbTab & vbTab & fld2.Value & vbCrLf
    rs.MoveNext
    Loop

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Deutz View Post
    I have a 2003 Access database with a table containing one number field and one text field and would like to be able to copy all records in that table into the clipboard ready for pasting into email or Word. When you copy and paste table contents manually you get the table outline and headings which is what I want. How can you do it with VBA though?

    Thanks in advance
    you should never have to do this through VBA.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 03-13-2010, 08:38 PM
  2. Distribute table contents evenly
    By arfaha in forum Access
    Replies: 0
    Last Post: 11-14-2009, 02:32 PM
  3. Updating one table with anothers contents
    By munkifisht in forum Access
    Replies: 0
    Last Post: 07-22-2009, 03:22 PM
  4. Replies: 0
    Last Post: 04-19-2008, 09:08 PM
  5. Clearing the clipboard with VBA?
    By Simon Sweet in forum Programming
    Replies: 1
    Last Post: 04-17-2008, 03:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums