Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete comment
Is there any verify vba to delete all comments in one
project VBE? Regards Mark |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete comment
Sounds fun.
I just put this together. You will need to add a reference to "Microsoft Visual Basic for Applications Extensibility" It handles string escape character and line continuations. Not really sure what else I should account for... Sub test() Dim vbc As VBComponent, i As Long, j As Long, str As String Dim blnStringMode As Boolean, blnLineContinue As Boolean For Each vbc In ThisWorkbook.VBProject.VBComponents blnStringMode = False i = 1 Do Until i vbc.CodeModule.CountOfLines str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") For j = 1 To Len(str) Select Case Mid(str, j, 1) Case """": blnStringMode = Not blnStringMode Case "'" If Not blnStringMode Then str = RTrim(Mid(str, 1, j - 1)) If LTrim(str) = "" Then vbc.CodeModule.DeleteLines i i = i - 1 Else vbc.CodeModule.ReplaceLine i, str End If If blnLineContinue Then i = i + 1 Do str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") vbc.CodeModule.DeleteLines i Loop While blnLineContinue i = i - 1 End If End If End Select Next i = i + 1 Loop Next End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Mark" wrote in message ... Is there any verify vba to delete all comments in one project VBE? Regards Mark |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete comment
Hi Rob!
Thanks for help! Regards Mark -----Original Message----- Sounds fun. I just put this together. You will need to add a reference to "Microsoft Visual Basic for Applications Extensibility" It handles string escape character and line continuations. Not really sure what else I should account for... Sub test() Dim vbc As VBComponent, i As Long, j As Long, str As String Dim blnStringMode As Boolean, blnLineContinue As Boolean For Each vbc In ThisWorkbook.VBProject.VBComponents blnStringMode = False i = 1 Do Until i vbc.CodeModule.CountOfLines str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") For j = 1 To Len(str) Select Case Mid(str, j, 1) Case """": blnStringMode = Not blnStringMode Case "'" If Not blnStringMode Then str = RTrim(Mid(str, 1, j - 1)) If LTrim(str) = "" Then vbc.CodeModule.DeleteLines i i = i - 1 Else vbc.CodeModule.ReplaceLine i, str End If If blnLineContinue Then i = i + 1 Do str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") vbc.CodeModule.DeleteLines i Loop While blnLineContinue i = i - 1 End If End If End Select Next i = i + 1 Loop Next End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Mark" wrote in message ... Is there any verify vba to delete all comments in one project VBE? Regards Mark . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete comment
Having taken another look at my code, I see some room for improvement:
Sub test() Dim vbc As VBComponent, i As Long, j As Long, str As String Dim blnStringMode As Boolean, blnLineContinue As Boolean For Each vbc In ThisWorkbook.VBProject.VBComponents blnStringMode = False i = 1 Do Until i vbc.CodeModule.CountOfLines str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") For j = 1 To Len(str) Select Case Mid(str, j, 1) Case """": blnStringMode = Not blnStringMode Case "'" If Not blnStringMode Then str = RTrim(Mid(str, 1, j - 1)) If LTrim(str) = "" Then vbc.CodeModule.DeleteLines i i = i - 1 Else vbc.CodeModule.ReplaceLine i, str End If Do While blnLineContinue blnLineContinue = (Right(vbc.CodeModule.Lines(i + 1, 1), 2) = " _") vbc.CodeModule.DeleteLines i + 1 Loop Exit For End If End Select Next i = i + 1 Loop Next End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Mark" wrote in message ... Hi Rob! Thanks for help! Regards Mark -----Original Message----- Sounds fun. I just put this together. You will need to add a reference to "Microsoft Visual Basic for Applications Extensibility" It handles string escape character and line continuations. Not really sure what else I should account for... Sub test() Dim vbc As VBComponent, i As Long, j As Long, str As String Dim blnStringMode As Boolean, blnLineContinue As Boolean For Each vbc In ThisWorkbook.VBProject.VBComponents blnStringMode = False i = 1 Do Until i vbc.CodeModule.CountOfLines str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") For j = 1 To Len(str) Select Case Mid(str, j, 1) Case """": blnStringMode = Not blnStringMode Case "'" If Not blnStringMode Then str = RTrim(Mid(str, 1, j - 1)) If LTrim(str) = "" Then vbc.CodeModule.DeleteLines i i = i - 1 Else vbc.CodeModule.ReplaceLine i, str End If If blnLineContinue Then i = i + 1 Do str = vbc.CodeModule.Lines(i, 1) blnLineContinue = (Right(str, 2) = " _") vbc.CodeModule.DeleteLines i Loop While blnLineContinue i = i - 1 End If End If End Select Next i = i + 1 Loop Next End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "Mark" wrote in message ... Is there any verify vba to delete all comments in one project VBE? Regards Mark . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copy comment content to cell content as data not as comment | Excel Discussion (Misc queries) | |||
How can I edit a comment w/o first having to select Show Comment | Excel Discussion (Misc queries) | |||
Code to delete all comment boxes | Excel Discussion (Misc queries) | |||
How do I insert a comment when the Insert:Comment menu is greyed? | Excel Discussion (Misc queries) | |||
a comment plugin & copy paste directly from excel to comment ? fr. | Excel Worksheet Functions |