This website uses cookies to ensure you get the best experience on our website. By using our website you agree on the following Cookie Policy, Privacy Policy, and Terms Of Use
This VBA macro extracts the text from all comments of the active document and displays it in a single message box.
Dim swApp As SldWorks.SldWorks
Sub main()
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
IfNot swModel IsNothingThenDim swFeat As SldWorks.Feature
Set swFeat = swModel.FirstFeature
Dim msg AsStringWhileNot swFeat IsNothingIf swFeat.GetTypeName() = "CommentsFolder"ThenDim swCommentsFolder As SldWorks.CommentFolder
Set swCommentFolder = swFeat.GetSpecificFeature2
Dim vComments AsVariant
vComments = swCommentFolder.GetComments
Dim i AsIntegerIfNot IsEmpty(vComments) ThenFor i = 0 To UBound(vComments)
Dim swComment As SldWorks.Comment
Set swComment = vComments(i)
msg = IIf(msg = "", "", msg & vbLf) & swComment.Text
Next i
EndIfEndIfSet swFeat = swFeat.GetNextFeature
Wend
If msg <> ""Then
swApp.SendMsgToUser2 msg, swMessageBoxIcon_e.swMbInformation, swMessageBoxBtn_e.swMbOk
EndIfElse
MsgBox "Please open model"EndIfEndSub