DocAElstein
Banned user
- Joined
- May 24, 2014
- Messages
- 1,336
Hi,
. I have been learning Excel VBA through participation in this board on and off for the last year.
.- I have no real experience with WORD VBA. WORD I mostly use for simple text Files.
. Occasionally I need to do simple substitution of selected bits of text or remove bits from selected bits of text.
. When the text is big I do a quick macro by “cheating” and using the Macro recorder whilst using the spreadsheet search and replace dialogue box thing..
……
. I hit a problem when I want to remove an ENTER and an ENTER from selected data..
. For example, I have this text selected in WORD
[tr][td]1[/td][td] Alan’s [/td][/tr]
[tr][td]]2[td][td] Nuts [/td][/tr]
… and I want the macro to work on that selected text to return this
[tr][td]1[/td][td] Alan’s [/td][/tr][tr][td]2[td][td] Nuts [/td][/tr]
… in this case the macro has removed the combination of an ENTER and an ENTER ( Knocked out 2 ENTERs which were alongside each other ) (In the practice I have lots of theses and I want all occurrences of a double ENTER to be knocked out
… can anyone give me the code or code line that does this?
.. below is the sort of code I get from the Macro recorder if I want to knock out spaces , it turns this
[tr][td]1[/td][td] Alan’s [/td][/tr]
[tr][td]]2[td][td] Nuts [/td][/tr]
Into this
[tr][td]1[/td][td]Alan’s[/td][/tr]
[tr][td]]2[td][td]Nuts[/td][/tr]
.. so maybe I just need the thing what says ENTER ENTER instead of “ “ in this line ?
[/CODE]
Or any non macro invented code would be better as I am keen to learn the right way to do this sort of thing with a macro.
Thanks
Alan
P.s.
I have to do a lot of this fiddling about when I paste a BB code or HTML Code from the clipboard into WORD when what I have in the clipboard was got with the MrExcel Screen shot Posting Tools.
. So maybe there is a way to get the Clipboard to paste the stuff in properly. That might be an alternative solution to this and other problems. But this is a messy one… Somehow the MrExcel Editor does or does not sometimes remove spaces between text ( A very inconsistent problem I find which can be Browser dependant………………………….
. I have been learning Excel VBA through participation in this board on and off for the last year.
.- I have no real experience with WORD VBA. WORD I mostly use for simple text Files.
. Occasionally I need to do simple substitution of selected bits of text or remove bits from selected bits of text.
. When the text is big I do a quick macro by “cheating” and using the Macro recorder whilst using the spreadsheet search and replace dialogue box thing..
……
. I hit a problem when I want to remove an ENTER and an ENTER from selected data..
. For example, I have this text selected in WORD
[tr][td]1[/td][td] Alan’s [/td][/tr]
[tr][td]]2[td][td] Nuts [/td][/tr]
… and I want the macro to work on that selected text to return this
[tr][td]1[/td][td] Alan’s [/td][/tr][tr][td]2[td][td] Nuts [/td][/tr]
… in this case the macro has removed the combination of an ENTER and an ENTER ( Knocked out 2 ENTERs which were alongside each other ) (In the practice I have lots of theses and I want all occurrences of a double ENTER to be knocked out
… can anyone give me the code or code line that does this?
.. below is the sort of code I get from the Macro recorder if I want to knock out spaces , it turns this
[tr][td]1[/td][td] Alan’s [/td][/tr]
[tr][td]]2[td][td] Nuts [/td][/tr]
Into this
[tr][td]1[/td][td]Alan’s[/td][/tr]
[tr][td]]2[td][td]Nuts[/td][/tr]
Code:
Code:
Sub KnockSpacesOut()
Selection.Find.Text = " "
Selection.Find.Replacement.Text = ""
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
.. so maybe I just need the thing what says ENTER ENTER instead of “ “ in this line ?
Code:
[CODE]Selection.Find.Text = " "
Or any non macro invented code would be better as I am keen to learn the right way to do this sort of thing with a macro.
Thanks
Alan
P.s.
I have to do a lot of this fiddling about when I paste a BB code or HTML Code from the clipboard into WORD when what I have in the clipboard was got with the MrExcel Screen shot Posting Tools.
. So maybe there is a way to get the Clipboard to paste the stuff in properly. That might be an alternative solution to this and other problems. But this is a messy one… Somehow the MrExcel Editor does or does not sometimes remove spaces between text ( A very inconsistent problem I find which can be Browser dependant………………………….