Share via

MS Access data into Clipboard

Anonymous
2010-12-17T10:44:38+00:00

Hi there,

I'm, using MS Access 2003 SP3 with winXP and i want to put some data into the clipboard using VB.

I have tried this:

Option Compare Database

Option Explicit

Dim MyData As DataObject

Private Sub CmdBoka_Click()

Set MyData = New DataObject

Dim Str As String, i As Integer

For i = 0 To Me.ValAnstNr.ListCount - 1

      If Me.ValAnstNr.Selected(i) = True Then

         Str = Str & Me.ValAnstNr.ItemData(i) & vbNewLine

      End If

    Next i

    MyData.SetText Str

    MyData.PutInClipboard ......

without success, Please help whats wrong?

Microsoft 365 and Office | Install, redeem, activate | For home | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2010-12-20T08:42:13+00:00

You've got the wrong kind of DataObject - the one that belongs to XDocument instead of MSForms. Change the declaration

Dim MyData As DataObject

to

Dim MyData As MSForms.DataObject

and also use

Set MyData = New MSForms.DataObject

Was this answer helpful?

0 comments No comments

9 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-12-17T14:15:40+00:00

    Perhaps a part of the problem i solved...

    Now it's stuck on row "MyData.SetTextStr Str"

    Error msg: Compile error - Method or data member not found

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2010-12-17T13:15:42+00:00

    Does it work if you use

    Set MyData = New MSForms.DataObject

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-12-17T13:11:20+00:00

    Yes, I already have made that reference.

    The error I get is : Compile error  - Invalid use of New keyword

    Was this answer helpful?

    0 comments No comments
  4. HansV 462.6K Reputation points
    2010-12-17T12:02:20+00:00

    It works when I try it. Have you set a reference to the Microsoft Forms 2.0 Object Library in Tools | References? You have to browse to find the DLL, it's C:\Windows\System32\FM20.dll.

    Was this answer helpful?

    0 comments No comments