FIND TEXT IN DRAWING

HOW TO FIND A TEXT IN A DRAWING USING MACRO. I FOUND THE EXAMPLE IN API BUT IT IS NOT WORKING

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim longstatus As Long

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

' Find and replace annotations

Set swUtil = swApp.GetAddInObject("Utilities.UtilitiesApp")

Set swUtilFindReplaceAnnotations = swUtil.FindReplaceAnnotations

longstatus = swUtilFindReplaceAnnotations.InitPMPage()

swUtilFindReplaceAnnotations.FindText = "abc"

swUtilFindReplaceAnnotations.ReplaceText = "def"

swUtilFindReplaceAnnotations.options = gtFraWholeWord

swUtilFindReplaceAnnotations.AnnotationFilter = gtFraNote

longstatus = swUtilFindReplaceAnnotations.FindNext()

longstatus = swUtilFindReplaceAnnotations.Replace()

longstatus = swUtilFindReplaceAnnotations.Close()

End Sub

COULD SOMEONE HELP ME IN THIS REGARD BY MODIFYING THE ATTACHED MACRO.

SolidworksApi macros
Answers 8
DG
DG 2009-11-04 Best Answer
Check this Change Note
SF
SF 2009-11-04

deepak,

   thanks for the macro.

   this macro works well if i select the text in the drawing and run the macro.

   But i am looking for a macro that will search a test and replace it with new text.

Thanks once again for taking time on this.

DG
DG 2009-11-04
Go to add in and select the "Utilities" and then try.
SF
SF 2009-11-04

Thanks deepak,

     It worked for my macro.

DG
DG 2009-11-04

Actually you are doing a Find and replace and SolidWorks Utilities are required for that.

SF
SF 2009-11-06

I want the macro when there is no annoation (text) in the drawing. how to do that .

for example if a drawing has annotation text saying "ALL DIMENSIONS ARE IN MM" then my macro should not run.

else if the drawing doesn't have annotation text saying "ALL DIMENSIONS ARE IN MM" then the macro has to work.

DG
DG 2009-11-09

TRY

Dim instance As IFindReplaceAnnotations<br>Dim value As String<br><br>instance.FindText = value<br><br>value = instance.FindText<br>
SF
SF 2009-11-12

Thanks deepak,

I am not good in macro could you please create a macro and send to me.

Thanks,