BASIC Macro to Copy textbox value to clipboard

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
himatech
Posts: 2
Joined: Fri May 22, 2015 5:19 pm

BASIC Macro to Copy textbox value to clipboard

Post 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..
OpenOffice 4.0.1
MacOS 10.10.3
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: BASIC Macro to Copy textbox value to clipboard

Post by Villeroy »

Please do it manually.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
himatech
Posts: 2
Joined: Fri May 22, 2015 5:19 pm

Re: BASIC Macro to Copy textbox value to clipboard

Post by himatech »

Manually! Can't BASIC handle such things?
OpenOffice 4.0.1
MacOS 10.10.3
User avatar
RoryOF
Moderator
Posts: 35064
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: BASIC Macro to Copy textbox value to clipboard

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
dndn
Posts: 1
Joined: Tue Jun 23, 2015 5:46 pm

Re: BASIC Macro to Copy textbox value to clipboard

Post 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
Apache OpenOffice 4.1.1
Windows 7 SP1
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: BASIC Macro to Copy textbox value to clipboard

Post by Villeroy »

dndn wrote:CreateUnoService( _
"com.sun.star.datatransfer.clipboard.SystemClipboard")
Thanks.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply