kann mir einer sagen, wie man den Inhalt einer Stringvariablen in die Zwischenablage kopieren kann?
Grüße
Kalle
Option Explicit
Private Declare Function OpenClipboard Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32.dll" () As Long
Private Declare Function EmptyClipboard Lib "user32.dll" () As Long
Private Declare Function SetClipboardData Lib "user32.dll" ( _
ByVal wFormat As Long, _
ByVal hMem As Long) As Long
Private Declare Function GlobalAlloc Lib "kernel32.dll" ( _
ByVal wFlags As Long, _
ByVal dwBytes As Long) As Long
Private Declare Function GlobalLock Lib "kernel32.dll" ( _
ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32.dll" ( _
ByVal hMem As Long) As Long
Private Declare Function GlobalFree Lib "kernel32.dll" ( _
ByVal hMem As Long) As Long
Private Declare Function lstrcpy Lib "kernel32" ( _
ByVal lpStr1 As Any, _
ByVal lpStr2 As Any) As Long
Private Const CF_TEXT As Long = 1&
Private Const GMEM_MOVEABLE As Long = 2
Sub Test()
Call StringToClipboard("Hallo ...")
End Sub
Private Sub StringToClipboard(s As String)
Dim hMem As Long
Dim hPtr As Long
hMem = GlobalAlloc(GMEM_MOVEABLE, Len(s) + 1)
hPtr = GlobalLock(hMem)
lstrcpy hPtr, s
GlobalUnlock hMem
OpenClipboard 0&
EmptyClipboard
SetClipboardData CF_TEXT, hMem
CloseClipboard
GlobalFree hMem
End Sub
Gruß
Thomas
Risi Thomas Softwareentwicklung
COM-Addins +++ RTD-Server +++ Komponenten
Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden
Suche nach den besten AntwortenEntdecke unsere meistgeklickten Beiträge in der Google Suche
Top 100 Threads jetzt ansehen