' MacroName: MarcPaste ' MacroDescription: Paste Libs-formulated MARC data from the clipboard ' Written by: Joel Hahn, Niles Public Library District Option Explicit Const CF_TEXT = 1 Const GMEM_SHARE = &H2000 'optional Const GMEM_MOVEABLE = &H2 Const GMEM_ZEROINIT = &H40 Const FOR_CLIPBOARD = GMEM_MOVEABLE Or GMEM_ZEROINIT Or GMEM_SHARE 'may omit GMEM_SHARE Declare Function OpenClipboard Lib "user.dll" (ByVal hwnd As Integer) _ As Integer Declare Function CloseClipboard Lib "user.dll" () As Integer Declare Function EmptyClipboard Lib "user.dll" () As Integer Declare Function SetClipboardData Lib "user.dll" (ByVal wFormat As _ Integer, ByVal hMem As Integer) As Integer Declare Function GetClipboardData Lib "user.dll" (ByVal wFormat As Integer) _ As Integer Declare Function GlobalAlloc Lib "krnl386.exe" (ByVal wFlags As Integer, _ ByVal dwBytes As Long) As Integer Declare Function GlobalLock Lib "krnl386.exe" (ByVal hMem As Integer) As Long Declare Function GlobalUnlock Lib "krnl386.exe" (ByVal hMem As Integer) As _ Integer Declare Function GlobalFree Lib "krnl386.exe" (ByVal hMem As Long) As Integer Declare Sub CopyMemory Lib "krnl386.exe" Alias "hmemcpy" (hpvDest _ As Any, hpvSource As Any, ByVal cbCopy As Long) Declare Function lstrcpy Lib "krnl386.exe" (lpToString As Any, _ lpFromString As Any) As Integer Declare Function lstrlen Lib "krnl386.exe" (ByVal lpString As Any) _ As Integer sub main Dim hMem As Integer Dim pMem As Long Dim retval As Integer Dim OutData$ Dim CS as Session Set CS = CurrentSession If OpenClipboard(0) Then hMem = GetClipboardData(CF_TEXT) pMem = GlobalLock(hMem) retval = lstrlen(ByVal pMem) OutData$ = Space$(retval) retval = lstrcpy(ByVal OutData$, ByVal pMem) 'CopyMemory OutData$, ByVal pMem, Len() retval = GlobalUnlock(hMem) retval = GlobalFree(pMem) retval = CloseClipboard() End If 'OutData$ = Left(OutData$, Len(OutData$)-1) 'MsgBox "/" & OutData$ & "/" CS.Send OutData$ '+Chr(9) end sub