Sonderzeichen bei der Zwischenablage
Sebastian
ich habe wiedermal ein Problem. Wenn ich mit unten aufgeführten Code den Inhalt der Windows zwischenablage in eine Variable schreibe und dann in Zelle B10, bekomme ich das Problem das sich am Ende Leerzeichen und ein Umbruch habe.
Ich weiß zwar das ich die mit Replace weg bekomme, aber irgendwie muß im Code doch ein Fehler sein das dies passiert.
Hat jemand eine Idee?
Vielen Dank
Sebastian
Public Function GetTextFromClipBoard1() As String
Dim workSheet1 As Worksheet
Dim range1 As Range
Dim formats As Variant
Dim format As Variant
Dim text As String
Application.ScreenUpdating = False
Workbooks.Add
Set range1 = ActiveSheet.Range("a1")
formats = Application.ClipboardFormats
text = ""
For Each format In formats
If (format = xlClipboardFormatText) Then
ActiveSheet.Paste Destination:=range1
Exit For
End If
Next format
If (Not ActiveSheet.UsedRange Is Nothing) Then
Dim row As Range
Dim column As Range
For Each row In ActiveSheet.UsedRange.Rows
For Each column In row.Cells
text = text & column.text
Next column
text = text & vbCrLf
Next row
End If
GetTextFromClipBoard1 = text
ActiveWorkbook.Close savechanges:=False
Application.ScreenUpdating = True
End Function
Sub test()Dim link As String
link = GetTextFromClipBoard1
Range("B10").Value = link
End Sub