# Revision history [back]

### I want to build a Specific Macro with Find Replace.

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th string elements into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

### I want to build a Specific Macro with Find Replace.

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. purpose.

1. Replace paragraph break with line break
2. [Keep what's there without the non-printing chars closed

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th string elements into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

### I want to build a Specific Macro with Find Replace.

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

1. Replace paragraph break with line break
2. [Keep what's there without the non-printing chars closed

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th string elements 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

### I want to build a Specific Macro with Find Replace.

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

1. Replace paragraph break with line break
2. [Keep what's there without the non-printing chars closed

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

### I want to build a Specific Macro with Find Replace.Find-Replace

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

### I want to build a Specific Macro with Find-Replace

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


Iif I try to run this second code, I can't find any result. Why? Where am I going wrong?

### I want to build a Specific Macro with Find-Replace

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


Iif If I try to run this second code, I can't find any result. Why? Where am I going wrong?

[Edited on 01/08/2017 in response to Librebel] You said

Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ... But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant C:\fakepath\test.odt This is the original file to be edited. C:\fakepath\tested.odt This is after the first macro run. C:\fakepath\WhatIwant.odt This is what I really want. I did try with nn in the second macro, but it doesn't work. Where am I going wrong? ### I want to build a Specific Macro with Find-Replace I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. Please refer to these posts: Recall the following: Paragraph character (¶): U+000D CR Carriage Return (0x0013) (entered at keyboard with Enter or Return key) Line-Break character (↲): U+000A LF Line Feed (0x00010) (entered at keyboard with Shift+Enter or Shift+Return key)  I want to build this macro: 1. I will have two String variables declared within the macro. 2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.)
3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark.
4. I then count the length of the string. Suppose this is n.
5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
6. I replace the first string with this second string.
7. I do this from the top every time, till there are no other such entries I wish to replace.

Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text. How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010) Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced: rem Replace all Paragraph Breaks With Linefeeds Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document. REM Returns: the number of found/replaced occurrences. Dim oReplace as Object oReplace = ThisComponent.createReplaceDescriptor() oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
oReplace.setReplaceString( "&" + chr(10) )
oReplace.SearchRegularExpression = True
Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
End Function


Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left.

REM Reiteration to remove empty paras after above action
Function Writer_ReplaceAll_Blank_Paras() As Long
Dim bReplace as Object
bReplace = ThisComponent.createReplaceDescriptor()
bReplace.setSearchString( chr(10) + "^$" ) bReplace.setReplaceString( chr(10) ) bReplace.SearchRegularExpression = True Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace ) End Function  If I try to run this second code, I can't find any result. Why? Where am I going wrong? [Edited on 01/08/2017 in response to Librebel] You said Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ...

But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant

C:\fakepath\test.odt This is the original file to be edited.

C:\fakepath\tested.odt This is after the first macro run.

C:\fakepath\WhatIwant.odt This is what I really want.

I did try with nn \n\n in the second macro, but it doesn't work. Where am I going wrong?

### I want to build a Specific Macro with Find-Replace

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


If I try to run this second code, I can't find any result. Why? Where am I going wrong?

[Edited on 01/08/2017 in response to Librebel] Librebel's advice] You saidsaid:

Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ... But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant C:\fakepath\test.odt This is the original file to be edited. C:\fakepath\tested.odt This is after the first macro run. C:\fakepath\WhatIwant.odt This is what I really want. I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong? ### I want to build a Specific Macro with Find-Replace I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. Please refer to these posts: Recall the following: Paragraph character (¶): U+000D CR Carriage Return (0x0013) (entered at keyboard with Enter or Return key) Line-Break character (↲): U+000A LF Line Feed (0x00010) (entered at keyboard with Shift+Enter or Shift+Return key)  I want to build this macro: 1. I will have two String variables declared within the macro. 2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.)
3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark.
4. I then count the length of the string. Suppose this is n.
5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
6. I replace the first string with this second string.
7. I do this from the top every time, till there are no other such entries I wish to replace.

Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text. How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010) Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced: rem Replace all Paragraph Breaks With Linefeeds Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document. REM Returns: the number of found/replaced occurrences. Dim oReplace as Object oReplace = ThisComponent.createReplaceDescriptor() oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
oReplace.setReplaceString( "&" + chr(10) )
oReplace.SearchRegularExpression = True
Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
End Function


Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left.

REM Reiteration to remove empty paras after above action
Function Writer_ReplaceAll_Blank_Paras() As Long
Dim bReplace as Object
bReplace = ThisComponent.createReplaceDescriptor()
bReplace.setSearchString( chr(10) + "^$" ) bReplace.setReplaceString( chr(10) ) bReplace.SearchRegularExpression = True Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace ) End Function  If I try to run this second code, I can't find any result. Why? Where am I going wrong? [Edited on 01/08/2017 in response to Librebel's advice] You said: Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ...

But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant

C:\fakepath\test.odt This is the original file to be edited.

C:\fakepath\tested.odt This is after running the first macro run.macro.

C:\fakepath\WhatIwant.odt This is what I really want.

I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong?

### I want to build a Specific Macro with Find-Replace

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


If I try to run this second code, I can't find any result. Why? Where am I going wrong?

[Edited on 01/08/2017 in response to Librebel's advice] You said:

Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ... But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant C:\fakepath\test.odt This is the original file to be edited. C:\fakepath\tested.odt This is after running the first macro. C:\fakepath\WhatIwant.odt This is what I really want. I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong? ### I want to build a Specific Macro with Find-Replace Particularly posted for Librebel with thanks: Yes, Hubert Lambert has solved this persistent problem at the Apache Open Office Forum: Solved: Match Individual Macro API with the API index? I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. Please refer to these posts: Recall the following: Paragraph character (¶): U+000D CR Carriage Return (0x0013) (entered at keyboard with Enter or Return key) Line-Break character (↲): U+000A LF Line Feed (0x00010) (entered at keyboard with Shift+Enter or Shift+Return key)  I want to build this macro: 1. I will have two String variables declared within the macro. 2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.)
3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark.
4. I then count the length of the string. Suppose this is n.
5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
6. I replace the first string with this second string.
7. I do this from the top every time, till there are no other such entries I wish to replace.

Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text. How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010) Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced: rem Replace all Paragraph Breaks With Linefeeds Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document. REM Returns: the number of found/replaced occurrences. Dim oReplace as Object oReplace = ThisComponent.createReplaceDescriptor() oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
oReplace.setReplaceString( "&" + chr(10) )
oReplace.SearchRegularExpression = True
Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
End Function


Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left.

REM Reiteration to remove empty paras after above action
Function Writer_ReplaceAll_Blank_Paras() As Long
Dim bReplace as Object
bReplace = ThisComponent.createReplaceDescriptor()
bReplace.setSearchString( chr(10) + "^$" ) bReplace.setReplaceString( chr(10) ) bReplace.SearchRegularExpression = True Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace ) End Function  If I try to run this second code, I can't find any result. Why? Where am I going wrong? [Edited on 01/08/2017 in response to Librebel's advice] You said: Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ...

But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant

C:\fakepath\test.odt This is the original file to be edited.

C:\fakepath\tested.odt This is after running the first macro.

C:\fakepath\WhatIwant.odt This is what I really want.

I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong?

### I want to build a Specific Macro with Find-Replace

Particularly posted for Librebel with thanks: Yes, Hubert Lambert has solved this persistent problem at the Apache Open Office Forum: Solved: Match Individual Macro API with the API index?

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


If I try to run this second code, I can't find any result. Why? Where am I going wrong?

[Edited on 01/08/2017 in response to Librebel's advice] You said:

Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ... But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant C:\fakepath\test.odt This is the original file to be edited. C:\fakepath\tested.odt This is after running the first macro. C:\fakepath\WhatIwant.odt This is what I really want. I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong? ### I [Solved]I want to build a Specific Macro with Find-Replace Particularly posted for Librebel with thanks: thanks for his intent to help: Yes, Hubert Lambert has solved this persistent problem at the Apache Open Office Forum: Solved: Match Individual Macro API with the API index? I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose. Please refer to these posts: Recall the following: Paragraph character (¶): U+000D CR Carriage Return (0x0013) (entered at keyboard with Enter or Return key) Line-Break character (↲): U+000A LF Line Feed (0x00010) (entered at keyboard with Shift+Enter or Shift+Return key)  I want to build this macro: 1. I will have two String variables declared within the macro. 2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.)
3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark.
4. I then count the length of the string. Suppose this is n.
5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element.
6. I replace the first string with this second string.
7. I do this from the top every time, till there are no other such entries I wish to replace.

Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text. How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010) Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced: rem Replace all Paragraph Breaks With Linefeeds Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document. REM Returns: the number of found/replaced occurrences. Dim oReplace as Object oReplace = ThisComponent.createReplaceDescriptor() oReplace.setSearchString( "[a-z,A-Z,0-9]$" )
oReplace.setReplaceString( "&" + chr(10) )
oReplace.SearchRegularExpression = True
Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace )
End Function


Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left.

REM Reiteration to remove empty paras after above action
Function Writer_ReplaceAll_Blank_Paras() As Long
Dim bReplace as Object
bReplace = ThisComponent.createReplaceDescriptor()
bReplace.setSearchString( chr(10) + "^$" ) bReplace.setReplaceString( chr(10) ) bReplace.SearchRegularExpression = True Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace ) End Function  If I try to run this second code, I can't find any result. Why? Where am I going wrong? [Edited on 01/08/2017 in response to Librebel's advice] You said: Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "$" ) ...

But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant

C:\fakepath\test.odt This is the original file to be edited.

C:\fakepath\tested.odt This is after running the first macro.

C:\fakepath\WhatIwant.odt This is what I really want.

I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong?

### [Solved]I want to build a Specific Macro with Find-Replace

Particularly posted for Librebel with thanks for his intent to help: help: Yes, Hubert Lambert has solved this persistent problem at the Apache Open Office Forum: Solved: Match Individual Macro API with the API index?

I have this C:\fakepath\example_txt.odt to show how I wish to use "Line Breaks" and "Paragraph Marks" to ease and automate the numbering of writing point-wise instruction steps. If I used Para mark somewhat differently in the text, I would have to manually engage in editing the document to suit my purpose.

Recall the following:

Paragraph character (¶): U+000D CR Carriage Return (0x0013)
(entered at keyboard with Enter or Return key)
Line-Break character (↲): U+000A LF Line Feed (0x00010)
(entered at keyboard with Shift+Enter or Shift+Return key)


I want to build this macro:

1. I will have two String variables declared within the macro.
2. I use Find with Wild Characters to find out texts like [a-z.A-Z.0-9]$. (These are usually the Title for the Paragraph.) 3. For the first string my find encounters, I take this entire string into the string variable, including the ¶mark. 4. I then count the length of the string. Suppose this is n. 5. I now take (n-1)th 'string-elements' into consideration, and fill the second string with this truncated string and the ↲ as the last element. 6. I replace the first string with this second string. 7. I do this from the top every time, till there are no other such entries I wish to replace. Presently, I am able to replace such strings like [a-z.A-Z.0-9]$ with #####&, the & code is used to print the ##### after the text but before the ¶mark to help me identify such lines. These marks help me in manually editing the text.

How could I build this macro? I used the macro recorder, but can't use the codes from within the macros for (): U+000D CR Carriage Return (0x0013) or (): U+000A LF Line Feed (0x00010)

Further Edited on 31/07/2017 at 1849Hrs (GMT+0530Hrs): Dear librebel One problem still remains: I learnt to understand your codes. Thank you for introducing me to StarBasic. Subsequently, I am in https://forum.openoffice.org. I partially modified the strings to be replaced:

rem Replace all Paragraph Breaks With Linefeeds
Function Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds() As Long
REM Replaces all Paragraph breaks with a Linefeed character within the current Writer document.
REM Returns: the number of found/replaced occurrences.
Dim oReplace as Object
oReplace = ThisComponent.createReplaceDescriptor()
oReplace.setSearchString( "[a-z,A-Z,0-9]$" ) oReplace.setReplaceString( "&" + chr(10) ) oReplace.SearchRegularExpression = True Writer_ReplaceAll_Paragraph_Breaks_With_Linefeeds = ThisComponent.replaceAll( oReplace ) End Function  Then I added another code to take care of the extra ¶mark after the ↲, because after running your modified code, I find that an extra empty para mark is left. REM Reiteration to remove empty paras after above action Function Writer_ReplaceAll_Blank_Paras() As Long Dim bReplace as Object bReplace = ThisComponent.createReplaceDescriptor() bReplace.setSearchString( chr(10) + "^$" )
bReplace.setReplaceString( chr(10)  )
bReplace.SearchRegularExpression = True
Writer_ReplaceAll_Blank_Paras = ThisComponent.replaceAll( bReplace )
End Function


If I try to run this second code, I can't find any result. Why? Where am I going wrong?

[Edited on 01/08/2017 in response to Librebel's advice] You said:

Perhaps you could use the following macro for that: ... ... oReplace.setSearchString( "\$" ) ...

But that line won't serve my purpose. I am enclosing the three files, Test, Tested and WhatIWant

C:\fakepath\test.odt This is the original file to be edited.

C:\fakepath\tested.odt This is after running the first macro.

C:\fakepath\WhatIwant.odt This is what I really want.

I did try with \n\n in the second macro, but it doesn't work. Where am I going wrong?