Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Macro for deleting specific comments

1,251 views
Skip to first unread message

MClaire

unread,
Jul 7, 2009, 1:03:01 PM7/7/09
to
Does anyone know how to create a macro to delete specific comments in at Word
2003 document? I'm looking for particularly to search by user (the person who
posted the comment) or by the content of the comment.

Thank you!

Lene Fredborg

unread,
Jul 7, 2009, 1:31:03 PM7/7/09
to
If you include the following code in a macro and replace the XXX by the
desired initials, all comments inserted by the person with the specified
initials will be deleted (the initials appear in square brackets in the
comments):

Dim oCom As Comment

If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If

For Each oCom In ActiveDocument.Comments
'Delete all comments made by person with the specified initials
If oCom.Initial = "XXX" Then
oCom.Delete
End If
Next oCom

-----------------------
To delete all comments that contain a specified string in the comment text,
you can use the following code. Replace XXX by the text you want to find:

Dim oCom As Comment

If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If

For Each oCom In ActiveDocument.Comments
'Delete all comments that include the text specified in "XXX"
If InStr(1, oCom.Range.Text, "XXX") > 0 Then
oCom.Delete
End If
Next oCom

If you need to run such macro often, you could add an InputBox that asks
about the desired initials or text string so that you do not need to change
it in the macro. Please post back if this is relevant and if you need help on
the InputBox part.

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word

MClaire

unread,
Jul 7, 2009, 3:50:02 PM7/7/09
to
So, would that look like:

Dim oCom As Comment, Dim strData as String


strData = InputBox("Delete all comments from the user ...", "Enter User
Initials")


If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If

For Each oCom In ActiveDocument.Comments
'Delete all comments made by person with the specified initials

If oCom.Initial = strData Then


oCom.Delete
End If
Next oCom

Maybe?

Lene Fredborg

unread,
Jul 7, 2009, 4:50:01 PM7/7/09
to
Try the version below:

Sub DeleteCommentsByInitials()
Dim oCom As Comment
Dim strData As String
Dim n As Integer

n = 0 'used to count deletions



If ActiveDocument.Comments.Count = 0 Then
MsgBox "No comments found."
Exit Sub
End If

Retry:


strData = InputBox("Delete all comments from the user ...", "Enter
UserInitials ")

If Len(strData) = 0 Then
If StrPtr(strData) = 0 Then
'Cancel clicked
Exit Sub
Else
'OK clicked, empty field
MsgBox "You must enter user initials. Please retry."
GoTo Retry
End If
Else
'Delete comments according to input


For Each oCom In ActiveDocument.Comments

If oCom.Initial = strData Then
oCom.Delete

n = n + 1
End If
Next oCom

End If

'Show msg with the result
MsgBox n & " comments deleted."

End Sub

------------
To create a corresponding macro for deleting comments containing a specific
string, you only need to replace the line:

If oCom.Initial = strData Then

with this line:

If InStr(1, oCom.Range.Text, strData) > 0 Then

raf...@editoracubo.com.br

unread,
Aug 12, 2015, 8:47:12 AM8/12/15
to
Lene
And if i want to remove several comments that contains diferent contents, for example: "XXX" and "YYY"?
I've tried to repeat the if but it stops...
Thanks.

Rafael

Stefan Blom

unread,
Aug 17, 2015, 3:41:22 PM8/17/15
to
If you are trying to delete comments that contain certain text strings,
you will have to use a macro such as the following:

Sub DeleteCommentWithSpecificText()
Dim c As Comment
Const SearchText$ = "text"

For Each c In ActiveDocument.Comments
If InStr(c.Range.Text, SearchText) Then
c.DeleteRecursively
End If
Next c
End Sub

Of course, you should change "text" to whatever text you are searching for.

Also, if you are using an older version of Word, replace
c.DeleteRecursively with c. Delete.

For assistance with installing the macro, see
http://www.gmayor.com/installing_macro.htm.

Stefan Blom
Microsoft Word MVP

พิม ชมชื่น

unread,
Dec 24, 2023, 7:05:58 PM12/24/23
to
➡️ 👉 1th.co/t?n=Bonus2024

💚💛💚ไอ้เราก็ติดใจเว็บนี้ช้ะด้วยสิ ถ้าไม่เล่นก็ว้าวุ้นเลยทีนี้💚💛💚
🟩🟨🟩เสียที่อื่นมาเยอะลองเปิดใจกับเว็ปนี้ดูค่ะไม่ผิดหวังแน่นอน🤑
🟩🟨🟩สมัครฟรีคลิก👉👉 1th.co/t?n=Bonus2024
🟩🟨🟩ทุนน้อยก็แตกได้ต้องลองแล้วป่ะ♨
🟩🟨🟩ฝากเร็ว-ถอนไว มียอดเสียให้ทุกวัน💸
🟩🟨🟩แอดมินบริการ24ชั่วโมง🥳
🟩🟨🟩รับทุกธนาคาร💰รองรับทูรวอเลท💸


🏓 🏓
➡️ 👉 1th.co/t?n=Bonus2024 💯
➡️ 👉 1th.co/t?n=Bonus2024 💯
➡️ 👉 1th.co/t?n=Bonus2024 💯

จากระบบทางเข้าเว็บตรง เว็บ สล็อตpgแตกง่าย เล่นสนุกและใช้งานที่นี่ -฿- สล็อต pg แตกง่าย ทางเข้าpg slot -฿- ในปัจจุบัน เว็บสล็อตออนไลน์ -฿- เพราะเรามี สล็อตเว็บตรง -฿- แตกหนัก จึงถือโอกาสแนะนำเกมสล็อตแตกง่ายจากค่าย pg slot ผู้ให้บริการ -฿- ระบบของสล็อตทรูวอลเลท สล็อตเว็บตรง -฿- เครดิตฟรีล่าสุด ดังนั้นแล้วหากคุณเป็นผู้ที่ชื่นชอบเกม สล็อตออนไลน์ -฿- มีมากฝากมาก มีน้อยฝากน้อย และไม่ว่าคุณจะฝากเท่าไหร่ ก็สามารถทำกำไรกับเว็บ สล็อต -฿- เพราะเราได้รวบรวม 10 อันดับเว็บเดิมพันสล็อตออนไลน์ที่ได้มาตรฐานระดับสากล -฿- สล็อตเว็บตรง ฝากถอนออโต้ -฿- สล็อตเว็บตรงแท้ ตัวอย่างค่ายเกมสล็อตที่มีให้บริการเช่น -฿- สมัครสมาชิก ติดต่อเรา สล็อตเว็บตรง -฿- ไม่ผ่านเอเย่นต์ มีความน่าเชื่อถือ สล็อตต่างประเทศ -฿- พร้อมทางเลือกเกมครบทุกค่าย สล็อต สนุกได้เต็มที่ลุ้นเงินรางวัลได้เต็มพิกัด -฿- นี้กันได้เลยมีแบรนด์ดังให้นักพนันได้เลือกใช้บริการ สล็อตเว็บตรง ฝาก-ถอน -฿- สล็อตเว็บตรง สล็อตเว็บตรงอันดับ1 -฿- สล็อตแตกหนัก สล็อตแตกง่าย -฿- เริ่มต้นใช้งานเกมสล็อตแนวอียิปห์กับ gods of giza -฿- vwrisiml รวมเกมสล็อต -฿- ไม่มี บัญชีธนาคาร ก่อนอื่นให้นักพนันเข้าไป สมัครเว็บสล็อตออนไลน์ ใหม่ล่าสุด -฿- ufa24 co a 24b สล็อตเว็บตรง -฿- สรุป สล็อตวอเลท เป็นบริการที่มีความทันสมัย และมีความสนุกสนาน เว็บสล็อตทรู -฿- มีสูตรไหนเหมาะกับคุณบ้าง เลือก ปั่นสล็อตเว็บตรง ที่มีค่า -฿- rtp 95 ขึ้นไป เพราะเกมสล็อตรูปแบบนี้ -฿- คอมโบสล็อตแตกรัวๆกับ fafa365 -฿- ได้เงินจริง เว็บสล็อตทรูวอเลท -฿- เว็บสล็อตทรูวอลเลท -฿- เว็บตรงสล็อต เล่นที่นี่ได้รับรางวัลใหญ่มูลค่ามากกว่า 1 ล้านบาทไม่ยากอย่างแน่นอน -฿- หากอยากทราบถึงสาเหตุที่ควรเล่น สล็อตเว็บตรง ทางเรามีคำตอบดีๆอย่างแน่นอน -฿- เกมสล็อตแตกง่าย สล็อตแตกง่าย แตกบ่อย เว็บสล็อตเว็บตรง ค่ายใหญ่ -฿- สมัยนี้ที่มีคาสิโนออนไลน์ เว็บสล็อตเกิดขึ้นมากมายเป็นดอกเห็ด -฿- เว็บสล็อตมาใหม่ อันดับ 1 ufs -฿- แล็ปท็อป และ ipads สล็อต -฿- จ่ายจริงที่ เว็บตรงสล็อต fafa365 skip -฿- รับ 100 สล็อตเว็บตรง มาพร้อมกับโปรโมชั่น ฝาก -฿- เว็บสล็อตออนไลน์ อันดับ -฿- วินาที สามารถเข้ามา สมัครเว็บสล็อต ที่ดีที่สุด เพื่อรับโบนัสเพิ่มทันที -฿- และทำไมจึงสำคัญ เมื่อคุณค้นหาเกมสล็อตออนไลน์ เพื่อเดิมพัน หลายคนมักจะเจอคำว่า -฿- สล็อตเว็บตรงฝากถอน true wallet ไม่มีขั้นต่ํา -฿- ได้เงินจริง เว็บสล็อตทรูวอเลท รวมสล็อตทุกค่าย หรือไม่ มีบริการเกมสล็อตออนไลน์ -฿- เว็บสล็อตทรู วอลเลท ยังให้บริการ ฝากเงินแบบไม่มีขั้นต่ำ -฿- ฝากถอนไม่มีขั้นต่ำ เว็บสล็อตที่ดีที่สุด เว็บทดลองเล่นสล็อตpg เว็บ -฿- และใช้งานง่าย ทำให้ เว็บสล็อต ยอดนิยม -฿- สล็อตpgแท้ รองรับการเข้าใช้งานผ่านช่องทางอย่าง มือถือ ครั้ง -฿- เว็บไซต์สล็อตหลายแห่งมักมี โหมดเล่นฟรีและโหมดทดลอง -฿- เว็บสล็อตฝากถอนผ่าน true wallet slot -฿- สล็อตออนไลน์ pgslot186 -฿- ที่สำคัญเว็บของเราที่เป็น สล็อตแตกง่าย -฿- เพื่อทำการ ทดลองเล่นสล็อต ต่าง ๆ ที่ให้บริการมากกว่า -฿- สล็อตเว็บตรง เว็บสล็อตวอเลท -฿- สล็อตpg สล็อตออนไลน์ เว็บเล่นเกม -฿- ไม่ผ่านเอเย่นต์ ไม่มีตัวกลาง ทำให้ผู้ใช้บริการ เว็บสล็อตออนไลน์


┏━━━━━━━🎯🎯━━━━━━━┓
🏆 ทางเข้าเว็บไซต์ 👉 1th.co/t?n=Bonus2024
📲 สมัครสมาชิก 👉 1th.co/t?n=Bonus2024
📞 ติดต่อสอบถาม 👉 1th.co/t?n=Bonus2024
┗━━━━━━━🎯🎯━━━━━━━┛

แสงสุข แสงสว่าง

unread,
Dec 26, 2023, 11:00:09 PM12/26/23
to
➡️ 👉 https://1th.co/f?l=Bonus2024

🌷 สุดปัง 🟣🟡🟣🟡🟣🟡🟣🟡🟣🟡🟣🟡
🟣แตกหนักมาก🟡แตกง่ายมาก🟣โบนัสแตกดี100%
🟣🟡สมัครฟรี 👉 https://1th.co/f?l=Bonus2024
🟣🟡สมัครใหม่ จัดหนักจัดเต็ม ไหลรัวๆ
🟣🟡ฝากถอน เริ่มต้นเพียง 1 บาท
🟣🟡 ระบบออโต้ ไม่ต้องทำเทิร์น


🎑 🎑
➡️ 👉 https://1th.co/f?l=Bonus2024 💯
➡️ 👉 https://1th.co/f?l=Bonus2024 💯
➡️ 👉 https://1th.co/f?l=Bonus2024 💯

เล่นที่นี่ได้รับรางวัลใหญ่มูลค่ามากกว่า 1 ล้านบาทไม่ยากอย่างแน่นอน สล็อตเว็บตรง - ทำให้ผู้เล่นสามารถสบายใจได้เลยว่าจะได้รับการเล่นสล็อตออนไลน์ - เว็บสล็อตใหม่ล่าสุด เว็บตรง ทดลองเล่นสล็อตpgฟรีได้เงินจริง - เกมส์ สล็อต pg เกม - ทดลองเล่นสล็อต ก่อนได้ - และสามารถทำกำไรในไม่ช้า ความสะดวกในการเล่นผ่าน เว็บตรงสล็อต - qilin เกมสล็อต ways - เข้าเล่น สล็อต - สล็อตเว็บตรง 100 - play เริ่มต้นใช้งานเกมสล็อตแนวอียิปห์กับ - สรุปเกี่ยวกับ เว็บสล็อต เว็บตรง pg แตกหนัก - สล็อต ฝาก ถอน - สล็อตแตกง่ายเว็บตรง ค่ายเกมสล็อต - รวดเร็วและทำรายการไวมากๆ สล็อตเว็บตรง - เว็บตรง pg สล็อตเว็บตรง คืออะไร - เลือกค่ายสล็อตไหนก็ได้ - ของโลก เข้ามา สมัครเว็บสล็อต ด้วยระบบอัตโนมัติสล็อตฝากถอน - สล็อต บอล ️ หวย - โดยเฉพาะทางเข้าของเรา คือ ระบบ สล็อต - ไม่ว่าจะเป็นการเล่นเกม หรือการทำธุรกรรมต่างๆ อยากเล่นเกม สล็อตเว็บตรง - ได้เงินจริง มีระบบทันสมัย และการฝากถอนเงินผ่านสล็อตเว็บตรง true wallet - เว็บสล็อตออนไลน์ที่ดีที่สุด สล็อตpg เว็บตรง แตกหนัก - คงจะหลีกเลี่ยงไม่ได้ว่า เว็บสล็อต - สล็อตเว็บตรงแตกง่าย เข้ามาสมัครผ่านระบบอัตโนมัติด้วยตนเอง - ค่ายเกม สล็อตเว็บตรง อัตราเเจ็คพอตเเตกมากที่สุด เกมใหม่น่าลงทุนของ สล็อตเว็บตรง - ลงทะเบียนใช้งานเล่นสล็อตที่นี่ไม่ผิดหวัง ผ่านระบบการเล่นที่รวดเร็วทุกช่องทาง แจก - https citly me l8hcw สล็อตเว็บตรงที่มีเกมสล็อตที่หลากหลาย - ที่ใช้งานผ่านทรูวอเลทของเรา เดิมพันกับประเภทเกม สล็อตเว็บตรง ของเราที่นี่ - สล็อตเว็บตรง เกมสล็อตสุดมันส์ เดิมพันไม่อั้น ปลอดภัยสูง - สล็อตpg สล็อต pg เว็บตรง - หากคุณกำลังมองหาประสบการณ์การเล่นสล็อตที่น่าตื่นเต้นและสนุกสนาน pg slot - เว็บตรงที่รวมเกมส์มากมายที่นี้ สล็อต https - ที่มี สล็อตแตกง่าย - ที่คุณไม่ควรพลาด โปรโมชั่น สล็อต - สล็อตเว็บตรง นั่นก็อาจจะทำให้คุณเสียอารมณ์ก็เป็นได้ - มีระบบสล็อต pg ออโต้


┏━━━━━━━🎯🎯━━━━━━━┓
🏆 ทางเข้าเว็บไซต์ 👉 https://1th.co/f?l=Bonus2024
📲 สมัครสมาชิก 👉 https://1th.co/f?l=Bonus2024
📞 ติดต่อสอบถาม 👉 https://1th.co/f?l=Bonus2024
┗━━━━━━━🎯🎯━━━━━━━┛

0 new messages