I have several pieces of text in a title block that I want to change.
I tried doing a record macro and it doesn't do it completely.
When I run the macro, I see it touch each piece of text in succession so
I am part way there. (Trying a different method than the search/replace
because I cannot assume the text value I am replacing is constant.)
I do know what it needs to be though...
I am looking into how to do a 'DoReplaceString strNote01.. for each item (boolstatus = item lines below)
that I want changed but do not know how to incorporate that function into my code.
(Admitting to being a total novice-wannabe-newbie programmer)
I am as interested in learning how to do this as much as getting it to work...
This is what I recorded and edited.
Adding my variables (the "mytext1" items will be replaced with the actual text I am to use of course)
Am I close or way off here?
Any help is appreciated!!
= = = = = == = == = == = == = == = == = == = == = == = == = =
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Dim strNote01 As String = "mytext1"
Dim strNote02 As String = "mytext2"
Dim strNote03 As String = "mytext3"
Dim strNote04 As String = "mytext4"
Dim strNote05 As String = "mytext5"
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.544872734994015, 6.84439369661325E-02, 0, False, 0, Nothing, 0)
Part.EditTemplate
Part.EditSketch
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("DetailItem2173@Sheet Format11", "NOTE", 0.551409013785214, 7.55404682251479E-02, 0, False, 0, Nothing, 0)
'Hoping I can replace the text selected here with my "mytext" item....
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("DetailItem2172@Sheet Format11", "NOTE", 0.552529518720848, 6.84439369661325E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("DetailItem2171@Sheet Format11", "NOTE", 0.555144030237327, 6.09739040619058E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("DetailItem2170@Sheet Format11", "NOTE", 0.542258223477536, 5.68653859645811E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("DetailItem2164@Sheet Format11", "NOTE", 0.57269860756226, 3.33347823162669E-02, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
Part.EditSheet
Part.EditSketch
'Part.ViewZoomtofit2
End Sub
SolidworksApi macros