Re: Textimport ohne Dialogbox
Verfasst: Di, 02.03.2010 15:17
Aloha
Von Haus aus lässt sich der Dialog glaube ich nicht verhindern.
Ich hab mit freundlicher Unterstützung von Andrew Pitonyak mal dieses Makro geschrieben, schau mal, ob das Deinen Ansprüchen genügt.
Von Haus aus lässt sich der Dialog glaube ich nicht verhindern.
Ich hab mit freundlicher Unterstützung von Andrew Pitonyak mal dieses Makro geschrieben, schau mal, ob das Deinen Ansprüchen genügt.
Code: Alles auswählen
Sub InsertClipboardAtCursor
If NOT Globalscope.BasicLibraries.isLibraryLoaded("Tools") Then
Globalscope.BasicLibraries.loadLibrary("Tools")
End If
oDoc = thisComponent
oSheet = oDoc.CurrentController.ActiveSheet
iPlainLoc = -1
oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oConverter = createUnoService("com.sun.star.script.Converter")
oClipContents = oClip.getContents
oTypes = oClipContents.getTransferDataFlavors
For i=LBound(oTypes) To UBound(oTypes)
If oTypes(i).MimeType = "text/plain;charset=utf-16" Then
iPlainLoc = i
Exit For
End If
Next
Dim aRow(0)
Dim aRowData(1) as String
nArrayIndex = 0
If (iPlainLoc >= 0) Then
convertedString = oConverter.convertToSimpleType _
(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
aLines = Split(convertedString,Chr(13))
For i = LBound(aLines) To UBound(aLines)
If Instr(aLines(i),Chr(9)) > 0 Then
aData = Split(aLines(i),Chr(9))
Redim Preserve aRow(nArrayIndex)
Redim aRowData(1)
aRowData(0) = aData(0)
aRowData(1) = aData(1)
aRow(nArrayIndex) = aRowData
nArrayIndex = nArrayIndex + 1
End If
Next i
nRow = oDoc.CurrentSelection(0).RangeAddress.StartRow
nCol = oDoc.CurrentSelection(0).RangeAddress.StartColumn
oRange = oSheet.getCellRangeByPosition(nCol,nRow,nCol+1,nRow+UBound(aRow))
oRange.setDataArray(aRow)
End If
End Sub