von polarbear » Do, 17.02.2011 22:14
Hallo Gemeinde,
wie kann der aktuelle Inhalt der Zwischenablage in die Tabellenzelle, in der der Cursor gerade steht, eingefügt werden.
Im Moment verwende ich ein Makro, das Text in das Dokument einfügt. Das funktioniert aber nicht, wenn der Cursor in einer Tabellenzelle steht:
Code: Alles auswählen
Sub ImportClipboard
Dim oClip, oClipContents, oTypes
Dim oConverter, convertedString$
Dim i%, iPlainLoc%
iPlainLoc = -1
oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oConverter = createUnoService("com.sun.star.script.Converter")
oClipContents = oClip.getContents()
oTypes = oClipContents.getTransferDataFlavors()
Dim msg$, iLoc%, outS
msg = ""
iLoc = -1
For i=LBound(oTypes) To UBound(oTypes)
If oTypes(i).MimeType = "text/plain;charset=utf-16" Then
iPlainLoc = i
Exit For
End If
'msg = msg & "Mime type = " & x(ii).MimeType & " normal = " & x(ii).HumanPresentableName & Chr$(10)
Next
If (iPlainLoc >= 0) Then
convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
myDoc=thisComponent
myViewCursor=myDoc.GetCurrentController.ViewCursor
myViewCursor.String = convertedString
Else
MsgBox "Nichts zum Einfügen vorhanden"
End If
End Sub
Ich vermute es liegt an diesen Zeilen
Code: Alles auswählen
convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
myDoc=thisComponent
myViewCursor=myDoc.GetCurrentController.ViewCursor
myViewCursor.String = convertedString
Wer kann helfen?
Dank und Gruß
polarbear
Moderation,4: ins zuständige Unterforum verschoben
Hallo Gemeinde,
wie kann der aktuelle Inhalt der Zwischenablage in die Tabellenzelle, in der der Cursor gerade steht, eingefügt werden.
Im Moment verwende ich ein Makro, das Text in das Dokument einfügt. Das funktioniert aber nicht, wenn der Cursor in einer Tabellenzelle steht:
[code]
Sub ImportClipboard
Dim oClip, oClipContents, oTypes
Dim oConverter, convertedString$
Dim i%, iPlainLoc%
iPlainLoc = -1
oClip = createUnoService("com.sun.star.datatransfer.clipboard.SystemClipboard")
oConverter = createUnoService("com.sun.star.script.Converter")
oClipContents = oClip.getContents()
oTypes = oClipContents.getTransferDataFlavors()
Dim msg$, iLoc%, outS
msg = ""
iLoc = -1
For i=LBound(oTypes) To UBound(oTypes)
If oTypes(i).MimeType = "text/plain;charset=utf-16" Then
iPlainLoc = i
Exit For
End If
'msg = msg & "Mime type = " & x(ii).MimeType & " normal = " & x(ii).HumanPresentableName & Chr$(10)
Next
If (iPlainLoc >= 0) Then
convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
myDoc=thisComponent
myViewCursor=myDoc.GetCurrentController.ViewCursor
myViewCursor.String = convertedString
Else
MsgBox "Nichts zum Einfügen vorhanden"
End If
End Sub
[/code]
Ich vermute es liegt an diesen Zeilen
[code]
convertedString = oConverter.convertToSimpleType(oClipContents.getTransferData(oTypes(iPlainLoc)), com.sun.star.uno.TypeClass.STRING)
myDoc=thisComponent
myViewCursor=myDoc.GetCurrentController.ViewCursor
myViewCursor.String = convertedString
[/code]
Wer kann helfen?
Dank und Gruß
polarbear
[color=#800000]Moderation,4[/color]: ins zuständige Unterforum verschoben