Hi,
Not sure would help anyway but don't want to use the Forms reference as not used elsewhere.
I have code that loops through records & creates a large string/text field e.g.
AllDatesX = "
Bob 1 June - 10 June : OK
Jack 15 July - 20 July : Not OK
Jim 20 Aug - 25 Aug : OK"
inc. CRLF etc.
ClipBoard_SetText (AllDatesX)
I then either Ctrl V or DoCmd.RunCommand acCmdPaste to put this inside a large memo/long rtf text field in the correct place. (Actually an email to send)
All works well & used for a long time but would really like "Not OK" to be in bold. Some times I manually do but hoped to be automated
I cannot work out a way to add this to a text string, adding html markups does not work, <strong> etc. etc.
Is there a way to do this?
I imagine perhaps set an unbound field (rtf) to the string, then copy paste that but think once did something like that years ago & all I can remember was not a good idea, can't remember why, or perhaps did not work so hopefully a cleaner way
Thanks I/A
not relevant but in case.
Not sure would help anyway but don't want to use the Forms reference as not used elsewhere.
I have code that loops through records & creates a large string/text field e.g.
AllDatesX = "
Bob 1 June - 10 June : OK
Jack 15 July - 20 July : Not OK
Jim 20 Aug - 25 Aug : OK"
inc. CRLF etc.
ClipBoard_SetText (AllDatesX)
I then either Ctrl V or DoCmd.RunCommand acCmdPaste to put this inside a large memo/long rtf text field in the correct place. (Actually an email to send)
All works well & used for a long time but would really like "Not OK" to be in bold. Some times I manually do but hoped to be automated
I cannot work out a way to add this to a text string, adding html markups does not work, <strong> etc. etc.
Is there a way to do this?
I imagine perhaps set an unbound field (rtf) to the string, then copy paste that but think once did something like that years ago & all I can remember was not a good idea, can't remember why, or perhaps did not work so hopefully a cleaner way
Thanks I/A
not relevant but in case.
Code:
Function ClipBoard_SetText(strCopyString As String) As Boolean
Dim hGlobalMemory As Long
Dim lpGlobalMemory As Long
Dim hClipMemory As Long
' Allocate moveable global memory.
'-------------------------------------------
hGlobalMemory = GlobalAlloc(GHND, Len(strCopyString) + 1)
' Lock the block to get a far pointer
' to this memory.
lpGlobalMemory = GlobalLock(hGlobalMemory)
' Copy the string to this global memory.
lpGlobalMemory = lstrcpy(lpGlobalMemory, strCopyString)
' Unlock the memory and then copy to the clipboard
If GlobalUnlock(hGlobalMemory) = 0 Then
If OpenClipboard(0&) <> 0 Then
Call EmptyClipboard
hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
ClipBoard_SetText = CBool(CloseClipboard)
End If
End If
End Function
Function ClipBoard_GetText() As String
Dim hClipMemory As Long
Dim lpClipMemory As Long
Dim strCBText As String
Dim retval As Long
Dim lngSize As Long
If OpenClipboard(0&) <> 0 Then
' Obtain the handle to the global memory
' block that is referencing the text.
hClipMemory = GetClipboardData(CF_TEXT)
If hClipMemory <> 0 Then
' Lock Clipboard memory so we can reference
' the actual data string.
lpClipMemory = GlobalLock(hClipMemory)
If lpClipMemory <> 0 Then
lngSize = GlobalSize(lpClipMemory)
strCBText = Space$(lngSize)
retval = lstrcpy(strCBText, lpClipMemory)
retval = GlobalUnlock(hClipMemory)
' Peel off the null terminating character.
strCBText = Left(strCBText, InStr(1, strCBText, Chr$(0), 0) - 1)
Else
MsgBox "Could not lock memory to copy string from."
End If
End If
Call CloseClipboard
End If
ClipBoard_GetText = strCBText
End Function
Function CopyOlePiccy(Piccy As Object)
Dim hGlobalMemory As Long, lpGlobalMemory As Long
Dim hClipMemory As Long, x As Long
' Allocate moveable global memory.
'-------------------------------------------
hGlobalMemory = GlobalAlloc(GHND, Len(Piccy) + 1)
' Lock the block to get a far pointer
' to this memory.
lpGlobalMemory = GlobalLock(hGlobalMemory)
'Need to copy the object to the memory here
lpGlobalMemory = lstrcpy(lpGlobalMemory, Piccy)
' Unlock the memory.
If GlobalUnlock(hGlobalMemory) <> 0 Then
MsgBox "Could not unlock memory location. Copy aborted."
GoTo OutOfHere2
End If
' Open the Clipboard to copy data to.
If OpenClipboard(0&) = 0 Then
MsgBox "Could not open the Clipboard. Copy aborted."
Exit Function
End If
' Clear the Clipboard.
x = EmptyClipboard()
' Copy the data to the Clipboard.
hClipMemory = SetClipboardData(CF_TEXT, hGlobalMemory)
OutOfHere2:
If CloseClipboard() = 0 Then
MsgBox "Could not close Clipboard."
End If
End Function
'********* Code End ************