Message 1 of 3
Macro to update style for Parts List Style
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello! If anyone in the Autodesk community could help me, I'd greatly appreciate it!
Problem statement: Our .idw drawings are using an outdated Parts List Style and need to be updated. I've created the new style that must be applied to all old .idw drawings. I have written a macro for engineers to use that checks the .idw for the old parts list style and replaces it with the new style. However, I get a "Run-time error 438" error at line oPartsListTable.Style.TableStyleName = newStyle
Below is the code referenced:
Sub UpdatePartsListStyle()
' Get the active drawing document
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Define the desired new style
Dim newStyle As String
newStyle = "Epicor Parts"
' Check if the active document is a drawing document
If Not oDrawDoc Is Nothing Then
' Check if there's a parts list table on the active sheet
If oDrawDoc.ActiveSheet.PartsLists.Count > 0 Then
' Assuming there's only one parts list table; adjust as needed
Dim oPartsListTable As PartsList
Set oPartsListTable = oDrawDoc.ActiveSheet.PartsLists.Item(1)
' Modify the parts list table style settings
oPartsListTable.Style.TableStyleName = newStyle
' Refresh the table to apply the changes
oPartsListTable.Refresh
' Notify the user
MsgBox "Parts List style updated to '" & newStyle & "'."
Else
MsgBox "No parts list table found on the active sheet."
End If
Else
MsgBox "The active document is not a drawing document."
End If
End Sub
Is this the right approach to updating the Parts List Style?