BASIC Macro to Copy textbox value to clipboard

Creating a macro - Writing a Script - Using the API

BASIC Macro to Copy textbox value to clipboard

Postby himatech » Sat May 23, 2015 1:38 pm

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
himatech
 
Posts: 2
Joined: Fri May 22, 2015 5:19 pm

Re: BASIC Macro to Copy textbox value to clipboard

Postby Villeroy » Sat May 23, 2015 3:51 pm

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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28551
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: BASIC Macro to Copy textbox value to clipboard

Postby himatech » Mon May 25, 2015 7:31 pm

Manually! Can't BASIC handle such things?
OpenOffice 4.0.1
MacOS 10.10.3
himatech
 
Posts: 2
Joined: Fri May 22, 2015 5:19 pm

Re: BASIC Macro to Copy textbox value to clipboard

Postby RoryOF » Mon May 25, 2015 7:43 pm

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.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 31436
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: BASIC Macro to Copy textbox value to clipboard

Postby dndn » Tue Jun 23, 2015 5:50 pm

Code: Select all   Expand viewCollapse view
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
dndn
 
Posts: 1
Joined: Tue Jun 23, 2015 5:46 pm

Re: BASIC Macro to Copy textbox value to clipboard

Postby Villeroy » Tue Jun 23, 2015 8:11 pm

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, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28551
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany


Return to Macros and UNO API

Who is online

Users browsing this forum: Google [Bot] and 4 guests