| View previous topic :: View next topic |
| Author |
Message |
Nalum Newbie

Joined: 04 Oct 2006 Posts: 3
|
Posted: Wed Oct 04, 2006 1:26 am Post subject: Carriage Returns |
|
|
Hello, I was wondering if there is a way to search the Document for carriage returns and change them to a word i.e.
"This is a Carriage
Return"
Would instead be:
"This is a Carriage &return; Return"
Thanks for all your help.
Nalum
P.S. I would need it to work with spreadsheets. |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Mon Oct 09, 2006 9:59 am Post subject: |
|
|
try this ... | Code: |
Sub Main
oSheet = ThisComponent.sheets.getByIndex(0)
oCursor = oSheet.createCursorByRange(oSheet.getCellbyPosition( 0, 0 ))
oCursor.GotoEndOfUsedArea(True)
lCol = oCursor.getRangeAddress().EndColumn
lRow = oCursor.getRangeAddress().EndRow
for kCol=0 to lCol
for kRow = 0 to lRow
oCell = oSheet.getCellByPosition(kCol, kRow)
s = oCell.String
if s <>"" then
kCR = InStr(s, Chr(10))
if kCR>0 then oCell.String = Left(s,kCR-1) & "&Return" & right(s, len(s)-kCR)
endif
next kRow
next kCol
End Sub |
|
|
| Back to top |
|
 |
Nalum Newbie

Joined: 04 Oct 2006 Posts: 3
|
Posted: Tue Oct 10, 2006 1:12 am Post subject: |
|
|
Thank you very much ms777.
Is there a way that I can get this to check more than once in each cell. At the moment it's only replacing one carrage return? |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Tue Oct 10, 2006 6:42 am Post subject: |
|
|
Yes. But this is easy ... good training in OO Basic for you  |
|
| Back to top |
|
 |
Nalum Newbie

Joined: 04 Oct 2006 Posts: 3
|
Posted: Tue Oct 10, 2006 6:43 am Post subject: |
|
|
Ok thanks again ms777  |
|
| Back to top |
|
 |
|