Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Macman45

macrumors G5
Jul 29, 2011
13,197
135
Somewhere Back In The Long Ago
Turn on the ¶ mode (Show all non printing characters), so your document shows all the hidden characters as a symbol, like space and return. Then it is easier to highlight and copy them into the Advanced Replace window. Just leave the "Replace with" field blank to delete, don't put a space in there or anything, just blank. I've been doing this in Word and Excel since the early 90s, almost daily. If you do this enough, you'll get used to how it works and you won't need the ¶ mode, anymore.

This works in Office For Mac 2011 for me...I wrestled with Macro after Macro, but Word is too dumb to "get it":) I was also solving a hardware issue yesterday...I'm convinced that a Macro SHOULD do this...
 

JAT

macrumors 603
Dec 31, 2001
6,473
124
Mpls, MN
This works in Office For Mac 2011 for me...I wrestled with Macro after Macro, but Word is too dumb to "get it":) I was also solving a hardware issue yesterday...I'm convinced that a Macro SHOULD do this...
A macro would just use Replace to do this. You'd want an input messagebox to allow the user to enter whatever text to delete. But really, Replace has been the way to do this problem since at least v4.0 of Word/Excel in 1992. Why bother programming something that is already programmed?

It is kinda annoying that they changed the shortcut on the Mac version though. Still CTRL-H on Windows.
 

Macman45

macrumors G5
Jul 29, 2011
13,197
135
Somewhere Back In The Long Ago
A macro would just use Replace to do this. You'd want an input messagebox to allow the user to enter whatever text to delete. But really, Replace has been the way to do this problem since at least v4.0 of Word/Excel in 1992. Why bother programming something that is already programmed?

It is kinda annoying that they changed the shortcut on the Mac version though. Still CTRL-H on Windows.

Shows just how long it's been since I used Word in any serious capacity....Now I just write letters....:)
 

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
Turn on the ¶ mode (Show all non printing characters), so your document shows all the hidden characters as a symbol, like space and return. Then it is easier to highlight and copy them into the Advanced Replace window. Just leave the "Replace with" field blank to delete, don't put a space in there or anything, just blank. I've been doing this in Word and Excel since the early 90s, almost daily. If you do this enough, you'll get used to how it works and you won't need the ¶ mode, anymore.

I did exactly what you have instructed. "Share" is gone but the blank line still stays there.

I'm neither an idiot nor an expert on Word, but so many different methods working for you don't work in my case. So, it's gotta be me.:(

Sorry guys, but I 'm giving up.

Thank you all for your time and concern.
Y'all be safe.
 

Macman45

macrumors G5
Jul 29, 2011
13,197
135
Somewhere Back In The Long Ago
I did exactly what you have instructed. "Share" is gone but the blank line still stays there.

I'm neither an idiot nor an expert on Word, but so many different methods working for you don't work in my case. So, it's gotta be me.:(

Sorry guys, but I 'm giving up.

Thank you all for your time and concern.
Y'all be safe.

One more go...Try this Macro:


The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub
 

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
One more go...Try this Macro:


The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub

Thank you MAcman45.

Am I to replace"connected" with my own word?
 

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
It's only a title..:) It certainly doesn't mean I'm a genius...It was fun solving this one as I used to write a lot of high end Macro stuff years and years ago...I have no use for them now...:)

I'm having difficulty with new macros.
I created the first one "Share" and then the second one "Report". I simply copy/pasted the first script into it, clicked edit and replaced the word "share" with "report". No problem.

Then I tried to create a third one with "Respond". Copy/paste again, but when I tried to edit, it messed up the first one "Share". I definitely didn't try to edit the wrong one.

Then, I tried a few other things out of desperation and now my macros look like this.


1) What did I mess up?
2) What is the difference between Module1 and Newmacros?
 

Attachments

  • macro.jpg
    macro.jpg
    35.2 KB · Views: 167

Macman45

macrumors G5
Jul 29, 2011
13,197
135
Somewhere Back In The Long Ago
I'm having difficulty with new macros.
I created the first one "Share" and then the second one "Report". I simply copy/pasted the first script into it, clicked edit and replaced the word "share" with "report". No problem.

Then I tried to create a third one with "Respond". Copy/paste again, but when I tried to edit, it messed up the first one "Share". I definitely didn't try to edit the wrong one.

Then, I tried a few other things out of desperation and now my macros look like this.


1) What did I mess up?
2) What is the difference between Module1 and Newmacros?


I think you need to name "NewMacros" to a more appropriate name. as it is it's screwing up the others as it's applying in all macros. I'd delete that one and create another with a name. You should end up with one for each word or string you need to delete.

----------

we know we have the right macro...It's a case of getting used to working with them...You are probably way ahead of this old guy!:D Keep trying, it will work.
 
Last edited:

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
I think you need to name "NewMacros" to a more appropriate name. as it is it's screwing up the others as it's applying in all macros. I'd delete that one and create another with a name. You should end up with one for each word or string you need to delete.

But that was my point exactly. I didn't give those names. Mine were simply "share" and "report". Then after I tried to add "respond", Word changed those names by itself.
 

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
Macman45 - Sorry for insisting.
I didn't read the last part of your message.

I'll keep on trying. Thank you for everything.
 

jendea

macrumors newbie
Jul 5, 2014
2
0
macros

One more go...Try this Macro:


The following macro should work

Sub DeleteParas()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="connected", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub

__________________
i have tried the above macro and it works with 1 line, however i would like to delete muliple lines with the same text, but the macro fails any ideas how to modifiy the above macro to achieve this?
 

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
i have tried the above macro and it works with 1 line, however i would like to delete muliple lines with the same text, but the macro fails any ideas how to modifiy the above macro to achieve this?

Do you mean you want to delete all the lines starting with a specific word, but the macro deletes only a single line instead of all?

If so, below is one of my macros deleting ALL lines in a text that start with "Recommend". You will notice the difference in the first line in bold.
Hope this helps

Sub Recommend()
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="Recommend", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub
End Sub
 
Last edited:

jendea

macrumors newbie
Jul 5, 2014
2
0
Hi
What I want to do is delete multiple paragraphs in a txt document with specific words the paragraph consist of 4 lines (repetitive) but the last word in the first line changes from p001 to p002 ect I have modded the macro is this correct
Line 1 I have successfully managed my team implementing the company process at all times poo1
Line 2 Proven track record for working under pressure at all times
Line 3 I am applying for the role, due to covering this for the last 4 years
Ect...

Repative line
Line 1 I have successfully managed my team implementing the company process at all times poo2
Line 2 Proven track record for working under pressure at all times
Line 3 I am applying for the role, due to covering this for the last 4 years

Sub DeleteParas()
Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="I have successfully managed my team, implementing the Company processes at all times p*^13", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="Proven track record for working and delivering under pressure,", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With

With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="I am applying for the role, due to covering this for the last 4 years", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub
 
Last edited:

aoitsukinosuke

macrumors regular
Original poster
Jun 13, 2011
116
0
Hi jendea,

What you are looking for is unfortunately beyond my knowledge. I hope someone answers and I can learn along. Sorry.

Hi
What I want to do is delete multiple paragraphs in a txt document with specific words the paragraph consist of 4 lines (repetitive) but the last word in the first line changes from p001 to p002 ect I have modded the macro is this correct
Line 1 I have successfully managed my team implementing the company process at all times poo1
Line 2 Proven track record for working under pressure at all times
Line 3 I am applying for the role, due to covering this for the last 4 years
Ect...

Repative line
Line 1 I have successfully managed my team implementing the company process at all times poo2
Line 2 Proven track record for working under pressure at all times
Line 3 I am applying for the role, due to covering this for the last 4 years

Sub DeleteParas()
Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="I have successfully managed my team, implementing the Company processes at all times p*^13", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="Proven track record for working and delivering under pressure,", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With

With Selection
.HomeKey wdStory
With .Find
.ClearFormatting
.Replacement.ClearFormatting
While .Execute(findText:="I am applying for the role, due to covering this for the last 4 years", _
MatchWholeWord:=True)
Selection.Range.Paragraphs(1).Range.Delete
Wend
End With
End With
End Sub
 

bulgaristani

macrumors newbie
Jun 24, 2017
1
0
Hello! Been struggling with the very same issue and came across this thread. Turns out there's such a function, though grim tricky, advanced stuff. After researching some more I figured out how to work around this. All you need to do is type in the Find what field "^p", followed by the text you wanna get rid of. Just type as you see it, without quote marks or space after it. Leave Replace with empty.

And here comes the funny part. I'm not a MS Office developer, neither even IT crew. I'm a lawyer.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.