Dennis McCann

Macro to Add Revision

Discussion created by Dennis McCann on Feb 3, 2020
Latest reply on Oct 15, 2020 by Gabe McGinn

Hey all,


I've been trying to create a macro which will automatically add a Rev Table with a predetermined revision into an already open drawing file. After recording what I'd like accomplished and cleaning up the code a bit, I have the following Macro (also attached): 


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

Set Part = swApp.ActiveDoc
Dim currentSheet As Object
Dim myRevisionTable As Object
Set currentSheet = Part.GetCurrentSheet
Set myRevisionTable = currentSheet.InsertRevisionTable2(False, 0.41578, 0.27005, swBOMConfigurationAnchor_TopRight, "C:\UECO Vault\Administration\Templates\SolidWorks Templates\Revision Table\Revision Table.sldrevtbt", swRevisionTable_TriangleSymbol, True)
Dim myTable As Object
Set myTable = Part.SelectionManager.GetSelectedObject5(1)
myTable.Text(1, 0) = "1"
myTable.Text(1, 1) = "INITIAL RELEASE"
myTable.Text(1, 3) = "DPM"

End Sub


This inputs the Rev Table format in the proper location on the drawing, but I get a run time error 91 on the bold line when I try to run this. I've looked at multiple other codes which perform similar functions, and I believe the issue I am having is with physically adding the next revision so the text can be inputted but I cannot figure out how to do that. My coding skills in VBA are amateur at best, so I would really appreciate any help I could get. I'm sure it's a simple fix that has been stumping me. Thanks.