Updating Revision Table with VBA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, my company is switching drawing templates and I've wrote a script that updates our drawing template but I'm having trouble with getting the revision table to work right. I've seen some code that uses RevisionTableStyles.Item and claims to work but I'm having an issue with mine and was wondering if anyone had any suggestions. The error I am getting is improper use of item, however I'm not sure what would be a better method.
Public Sub CopyDrawingResources()
If ThisApplication.ActiveDocument Is Nothing Then
Exit Sub
Else
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
Dim InvDoc As DrawingDocument
Set InvDoc = ThisApplication.ActiveDocument
Else
Exit Sub
End If
End If
Dim SourceDoc As DrawingDocument
Dim RevTab As RevisionTable
Dim RevTabStyle As RevisionTableStyle
Set SourceDoc = ThisApplication.Documents.Open("my drawing template", False)
On Error Resume Next
For Each Item In InvDoc.SheetFormats
If Item.IsRferenced = False Then Item.Delete
Next
For Each Item In InvDoc.BorderDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In InvDoc.TitleBlockDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In InvDoc.SketchedSymbolDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In SourceDoc.BorderDefinitions
Set TargetBorder = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.TitleBlockDefinitions
Set TargetHeader = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.SketchedSymbolDefinitions
Set TargetSymbol = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.SheetFormats
'Caution: this creates a new copy of the TitleBlock used for EACH SheetFormat,
'regardless if the TitleBlockDefinition already exists or not!!!
Set TargetSheet = Item.CopyTo(InvDoc)
Next
On Error GoTo 0
SourceDoc.ReleaseReference
SourceDoc.Close (True)
Set SourceDoc = Nothing
'Set RevTab = RevTab.Style
'InvDoc.StylesManager.RevisionTableStyles.Item.Delete
InvDoc.StylesManager.ActiveStandardStyle.UpdateFromGlobal
InvDoc.StylesManager.RevisionTableStyles.Item ("My Revision Table")
InvDoc.Update
End Sub