AnsweredAssumed Answered

Revision table macro

Question asked by Michael Raikh on Jul 6, 2015
Latest reply on Jul 20, 2015 by Bruce Perry

Hi,

i've been trying to run a macro i've built, it fills in the revision table.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Dim swApp As Object

 

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

 

Sub main()

 

 

Set swApp = _

Application.SldWorks

 

 

'Edit the Revision Table

Set Part = swApp.ActiveDoc

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.2653942284632, 0.2752584044808, 0, False, 0, Nothing, 0)

Dim currentSheet As Object

Dim myRevisionTable As Object

Set currentSheet = Part.GetCurrentSheet()

Set myRevisionTable = currentSheet.RevisionTable

longstatus = myRevisionTable.AddRevision("")

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.2498048865494, 0.2679361378244, 0, False, 0, Nothing, 0)

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.2498048865494, 0.2679361378244, 0, False, 0, Nothing, 0)

'Part.ClearSelection2 True

Dim myTable As Object

Set myTable = Part.SelectionManager.GetSelectedObject5(1)

myTable.Text(2, 0) = "#"

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.2656304306134, 0.2676999356742, 0, False, 0, Nothing, 0)

'Part.ClearSelection2 True

Set myTable = Part.SelectionManager.GetSelectedObject5(1)

myTable.Text(2, 1) = "-"

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.2814559746773, 0.2658103184725, 0, False, 0, Nothing, 0)

'Part.ClearSelection2 True

Set myTable = Part.SelectionManager.GetSelectedObject5(1)

myTable.Text(2, 2) = "0"

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.3147604778567, 0.2676999356742, 0, False, 0, Nothing, 0)

'Part.ClearSelection2 True

Set myTable = Part.SelectionManager.GetSelectedObject5(1)

myTable.Text(2, 3) = "New Part"

boolstatus = Part.Extension.SelectByID2("DetailItem504@Sheet1", "REVISIONTABLE", 0.3964864218288, 0.2676999356742, 0, False, 0, Nothing, 0)

'Part.ClearSelection2 True

Set myTable = Part.SelectionManager.GetSelectedObject5(1)

myTable.Text(2, 5) = "Yossi B.-ZAE"

 

 

'Delete the Path line at the bottom of the SHEET

boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.2299456113629, 0.09981751925915, 0, False, 0, Nothing, 0)

Part.EditTemplate

Part.EditSketch

Part.ClearSelection2 True

boolstatus = Part.Extension.SelectByID2("DetailItem503@Sheet Format1", "NOTE", 0.2930098110623, 0.00263396438633, 0, False, 0, Nothing, 0)

Part.EditDelete

Part.EditSheet

Part.EditSketch

End Sub

 

it runs into an Run-time error '91'.

 

it does work some times, some times not.

what could be the solution?

 

I'm running SW2010

Outcomes