Page 1 of 1

BASIC Macro to Copy textbox value to clipboard

Posted: Sat May 23, 2015 1:38 pm
by himatech
Hi,

I'm new to OO and I've looked everywhere to find the answer but unfortunately, I can't!

I want to create a button that call a macro to copy the value shown in a textbox in one of the forms within the database.

Example:
Text Box "Employer" is showing the value of "IBM". When I click the custom button, I need the value "IBM" to be copied to the clipboard.

Note: I'm using OO on Mac.

Thank..

Re: BASIC Macro to Copy textbox value to clipboard

Posted: Sat May 23, 2015 3:51 pm
by Villeroy
Please do it manually.

Re: BASIC Macro to Copy textbox value to clipboard

Posted: Mon May 25, 2015 7:31 pm
by himatech
Manually! Can't BASIC handle such things?

Re: BASIC Macro to Copy textbox value to clipboard

Posted: Mon May 25, 2015 7:43 pm
by RoryOF
I'm sure OO BASIC can, but can you write the macro you need? If you make a reasonable attempt you will find good help when we see your code.

Re: BASIC Macro to Copy textbox value to clipboard

Posted: Tue Jun 23, 2015 5:50 pm
by dndn

Code: Select all

Global sTxtCString As String 
  
Sub CopyToClipBoard( sText ) 
  Dim oClip, oTR
  ' create SystemClipboard instance 
  oClip = CreateUnoService( _ 
      "com.sun.star.datatransfer.clipboard.SystemClipboard") 
  oTR = createUnoListener("Tr_", _ 
      "com.sun.star.datatransfer.XTransferable") 
  ' set data 
  oClip.setContents( oTR,Null ) 
  sTxtCString = sText 
  'oClip.flushClipboard() ' does not work 
End Sub 
  
Function Tr_getTransferData( _ 
    aFlavor as com.sun.star.datatransfer.DataFlavor) 
  If (aFlavor.MimeType = "text/plain;charset=utf-16") Then 
    Tr_getTransferData() = sTxtCString 
  End If 
End Function 
  
Function Tr_getTransferDataFlavors() 
  Dim aFlavor As new com.sun.star.datatransfer.DataFlavor 
  aFlavor.MimeType = "text/plain;charset=utf-16" 
  aFlavor.HumanPresentableName = "Unicode-Text" 
  Tr_getTransferDataFlavors() = array( aFlavor ) 
End Function 
  
Function Tr_isDataFlavorSupported( _ 
    aFlavor as com.sun.star.datatransfer.DataFlavor ) as Boolean 
  If aFlavor.MimeType = "text/plain;charset=utf-16" Then 
    Tr_isDataFlavorSupported = true 
  Else 
    Tr_isDataFlavorSupported = false 
  End If 
End Function

Re: BASIC Macro to Copy textbox value to clipboard

Posted: Tue Jun 23, 2015 8:11 pm
by Villeroy
dndn wrote:CreateUnoService( _
"com.sun.star.datatransfer.clipboard.SystemClipboard")
Thanks.