Thanks for the help Jacob. I tried putting this command where you suggested and at various places in my script but it did not solve the problem. I was really hoping this would do the trick.
This was my final workaround for anyone else that encounters this issue
- Export the revision table as a csv file in the
- replace the revision table
- add all required rows back to the newly inserted table
- call the second macro using swApp.RunMacro
- import data from csv
- insert data into table
I know this might be redundant at this point since it sounds like you more or less figured this out but I stumbled through this same issue when writing my C# add-in to update the drawing template which includes updating the revision table.
Note, this is all in c# and can be translated to VBA relatively easily if you need to with translators available online.
I've found that SW wants things done in a specific order.
1.) Add a new row to the table with 2016 SOLIDWORKS API Help - AddRevision Method (IRevisionTableAnnotation)
2.) Create a reference to the TableAnnotation reference of the revision table
table = (TableAnnotation)revTable;
3.) To edit the cells in the table, use the following method.
table.Text[row, col] = "Your cell text here";
4.) If you have revision bubbles, these get tricky as it's easiest to add them back as you're creating rows with the following method. This will associate it with the last row currently in the revision table.
// re-add revision symbol to the location it was at previously and attach it to the correct view. swNote = drawing.InsertRevisionSymbol(symbolPosition, symbolPosition);
Alex, Thanks for the tip! Although it is not the exact answer, it did direct me towards finding the problem.
The problem was how I was getting the reference for the revision table after it was replaced. In my original script I used similar code to search for the revision table reference both before and after replacing the table. This technique of looping over all tables until a revision table is found does not seem to work after the table is replaced. Instead you must use the value returned by InsertRevisionTable to edit the table text.
Set rev_table_handle = swsht.InsertRevisionTable(True, 0, 0, swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopRight, "path") rev_table_handle.Text(1, 1) = "test"