我尝试使用宏来裁剪Calc中的空格。Trim函数似乎不起作用
我尝试使用Trim,LTrim,RTrim,但结果相同。有人知道哪里错了吗?
oCSL是“阿朗和法官”
oCSR和z在修剪后也应该像oCSL一样,但仍然留在"Arang和地方法官“。
代码如下:
Dim oAC As Object, oC As Object, oAS As Object, oCSL As String, oCSR As String
Dim oASn As Integer
Dim CellRangeAddress As New com.sun.star.table.CellRangeAddress
Dim CellAddress As New com.sun.star.table.CellAddress
oC = ThisComponent
oAS = oC.getcurrentcontroller.ActiveSheet
oASn = oC.getCurrentController().getActiveSheet().getRangeAddress().sheet
Dim Ll As Integer, Lc As Integer, r As Integer
Dim z As String, y As String
Ll = 400
Lc = 0
r = 400
' Read Each Left Side Line
Do
Do
' Locate Position For Right Side
Do
oCSL = Trim(UCase(oAS.getCellByPosition(Lc, Ll).String)) ' oSCL Value Returned "Arang and the Magistrate"
oCSR = Trim(UCase(oAS.getCellByPosition(7, r).String)) ' oCSR Value Returned "Arang and the Magistrate "
z = RTrim(oAS.getCellByPosition(7, r).String) ' z Returns Also "Arang and the Magistrate "
If strcomp(oCSL, oCSR) < 0 Then
ThisComponent.CurrentController.Select(oAS.getCellByPosition(7, r)) ' Reposition Selected Area
'ThisComponent.CurrentController.Select(oAS.getCellByPosition(Lc, Ll)) ' Reposition Selected Area
MsgBox ("At " & r & " Not Found " & Chr(13) & oCSL) ' Not Found
' Insert New Movie
Exit Do
else
If UCase(oCSL) = UCase(OcSR) Then
ThisComponent.CurrentController.Select(oAS.getCellByPosition(7, r)) ' Reposition Selected Area
'MsgBox ("At " & r & " Same Value " & oCSL) ' Same Value
r = r + 1
Exit Do
else
r = r + 1
End If
End If
Loop While Lc <= 4
Lc = Lc + 1
Loop While Lc <= 4
Ll = Ll + 1 ' Next Line
Lc = 0 ' Reset Column
Loop While oCSL <> "" ' getCellByPosition Starts From Col 0 Row 0发布于 2019-12-12 13:28:25
我找到原因了。在使用Asc()来判断它是否是空格之后,它不是空格,而是特殊字符。很抱歉打扰了大家。
https://stackoverflow.com/questions/59277608
复制相似问题