Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default delete comment

Is there any verify vba to delete all comments in one
project VBE?

Regards
Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
How can I edit a comment w/o first having to select Show Comment Mary Ann Excel Discussion (Misc queries) 1 August 26th 05 12:34 AM
Code to delete all comment boxes Shawn Excel Discussion (Misc queries) 1 June 2nd 05 03:21 PM
How do I insert a comment when the Insert:Comment menu is greyed? none Excel Discussion (Misc queries) 0 May 19th 05 12:36 AM
a comment plugin & copy paste directly from excel to comment ? fr. RFM Excel Worksheet Functions 0 December 1st 04 11:29 PM


All times are GMT +1. The time now is 01:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"