Is there some simple coding i can use to copy the contents of textbox to the clipboard????
Printable View
Is there some simple coding i can use to copy the contents of textbox to the clipboard????
What database are you using... if your talking about access you may be able to do it via macros.
I'm using MSAccess 2003.
I've kinda cheated, but then it works....
VB Code:
Dim copypasteUpdater As String copypasteUpdater = [ContractorName].Value & vbCrLf If [Address].Value <> "" Then copypasteUpdater = copypasteUpdater + [Address].Value & vbCrLf If [Town].Value <> "" Then copypasteUpdater = copypasteUpdater + [Town].Value & vbCrLf If [County].Value <> "" Then copypasteUpdater = copypasteUpdater + [County].Value & vbCrLf If [PostCode].Value <> "" Then copypasteUpdater = copypasteUpdater + [PostCode].Value [txtCopyPastebox].Value = copypasteUpdater txtCopyPastebox.SetFocus DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
I made txtCopyPastebox textbox 0cm wide and very small, and then put it beside my copy button.
would have preferred to copy copypasteUpdater string direct to clipboard, but nevermind!
This example uses the SetText method to copy text from a text box to the Clipboard. To try this example, paste the code into the Declarations section of a form with a text box named Text1, and then press F5 and click the form.
VB Code:
Private Sub Form_Click () Const CF_TEXT = 1 ' Define bitmap format. Dim I, Msg, Temp ' Declare variables. On Error Resume Next ' Set up error handling. Msg = "Type anything you like into the text box below." Text1.Text = InputBox(Msg) ' Get text from user. Msg = "Choose OK to copy the contents of the text box " Msg = Msg & "to the Clipboard." MsgBox Msg ' Display message. ClipBoard.Clear ' Clear Clipboard. Clipboard.SetText Text1.Text ' Put text on Clipboard. If Clipboard.GetFormat(CF_TEXT) Then Text1.Text = "" ' Clear the text box. Msg = "The text is now on the Clipboard. Choose OK " Msg = Msg & "to copy the text from the Clipboard back " Msg = Msg & "to the text box." MsgBox Msg ' Display message. Temp = Clipboard.GetText(CF_TEXT) ' Get Clipboard text. For I = Len(Temp) To 1 Step -1 ' Reverse the text. Text1.Text = Text1.Text & Mid(Temp, I, 1) Next I Else Msg = "There is no text on the Clipboard." MsgBox Msg ' Display error message. End If End Sub
I'm using MSAccess 2003.
the "Clipboard" is not a recognised object in Access.
if I remove the
VB Code:
On Error Resume Next ' Set up error handling.
line then I get an error saying "Run-time Error 424, Object Required."
at the
VB Code:
ClipBoard.Clear ' Clear Clipboard.
Line.
Is there a way of making the clipboard work???