AnsweredAssumed Answered

Macro hanging on one step - Changing Text

Question asked by Patrick Malone on Nov 24, 2015
Latest reply on Nov 24, 2015 by Ivana Kolin

I am attempting by this macro to change a piece if text.

I have a few hundred drawings and I need to change a specific piece of text to a specified value.

The current value is not always the same but it is always in the same place.

 

What I have at this point goes as far as selecting the text (it is highlighted)

I get a debugger error and the text is not changed.

 

Can someone please help me get past this one step.

 

================= CODE: ======================

 

Dim swApp As Object

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim swSelMgr        As SldWorks.SelectionMgr

Dim swNote          As SldWorks.Note

Dim bRet            As Boolean

Dim strNote01       As String

 

Sub main()

 

Set swApp = _

Application.SldWorks

 

strNote01 = "My Text"

 

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.69567916699979, 1.27146115981563E-02, 0, False, 0, Nothing, 0)

Part.EditTemplate

Part.EditSketch

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("DetailItem2203@Sheet Format10", "NOTE", 0.72358507099049, 1.51692975973382E-02, 0, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("DetailItem2203@Sheet Format10", "NOTE", 0.72358507099049, 1.51692975973382E-02, 0, False, 0, Nothing, 0)

 

Set swNote = swSelMgr.GetSelectedObject6(1, 0)   ' -> ROUTINE GETS AN ERROR RIGHT HERE

 

bRet = swNote.SetText(strNote01)

 

swModel.ForceRebuild3 (True)

 

swModel.ClearSelection2 (True)

 

 

Part.ClearSelection2 True

End Sub

 

============== =======================

 

As a Part 2 to this question,

I want to set this piece of text to this value:    $PRP:"Scale"

 

Other attempts at this won't allow me to specify this value.

 

ie:  strNote01 = " $PRP:"Scale" "

 

I don't understand the syntax required

Outcomes