Results 1 to 5 of 5
  1. #1
    Eduardo Ellery is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    2

    Copy the information of a field to the clipboard so I can paste it in a Word document using Sendkeys


    I want to use Sendkeys statement to copy the information of a text field to the clipboard and then paste it in a Word document.

    I used docmd.gotocontrol texto_documento to set the focus and then docmd.sendkeys "^C" to copy the text to the clipboard.

    It did not work. I tried using macros, but it did not work either. What am I doing wrong?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Instead of SendKeys try:

    DoCmd.RunCommand acCmdCopy
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    SendKeys should always be used as the absolute last resort, when nothing else will do the job, which isn't the case, here! I use the same command that June7 gave you, except that I believe you have to select the text, first, before copying.

    I also idiot-proof it, in case the user hits the button when the target field is empty, which will cause an error, if I remember correctly:

    Code:
    If Nz(Me.TextboxName, "") <> "" Then
      Me.TextboxName.SetFocus
      Me.TextboxName.SelLength = Len(Me.TextboxName)
      DoCmd.RunCommand acCmdCopy
    Else
      MsgBox "There's Nothing to Copy, Dummy!"
    End If

    Linq ;0)>!
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Eduardo Ellery is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Posts
    2
    June7's command worked perfectly. I will use the idiot-proof code Missinglinq gave too. Thank you both very much. Problem solved.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Glad we could help, and welcome to AFN!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Copy/paste/rename a field in the same form?
    By Jamesiv1 in forum Access
    Replies: 5
    Last Post: 04-26-2014, 10:22 AM
  2. Copy and Paste non-visable field
    By delap009 in forum Forms
    Replies: 2
    Last Post: 08-22-2013, 10:23 AM
  3. Replies: 3
    Last Post: 12-17-2011, 02:32 PM
  4. Exporting Memo field Data to Word document
    By samlennox in forum Programming
    Replies: 2
    Last Post: 04-25-2011, 11:57 PM
  5. Replies: 1
    Last Post: 03-13-2010, 08:38 PM

Tags for this Thread

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