I need help updating the source of a custom table in a drawing. I wrote a design copy rule that takes a template "module" and saves all the files off into the customer's project folder. This latest module has an orientation chart that details the location of key features and is displayed on the drawing. We're driving the chart using an external excel file. I can get the reference in the assembly to update with no problem by just telling the driving rule to look for an excel with matching project and assembly numbers in the same folder as the assembly.
However, when I try and update the reference in the drawing, I can get the "3rd Party" link to change, but it doesn't change the actual link in the table. Here's a pic of the tree and my part of the current code. How can I make it update the actual link?
Try Dim oSht As Sheet = oDwgDoc.Sheets.Item(1) Dim oChart As CustomTable = oSht.CustomTables.Item(1) MsgBox(oChart.Title) Dim oChartDesc As FileDescriptor = oChart.ReferencedDocumentDescriptor chartDocName = oDwgDoc.ReferencedDocumentDescriptors.Item(1).FullDocumentName If chartDocName.Contains("OrientationChart") Then MsgBox("The dude contains") End If orientChartName = Left(iProperties.Value("Custom", "OldName"), 3) & Parameter("projectNum") & Parameter("itemNum") & "OrientationChart.xlsx" orientChartPath = System.IO.Path.GetDirectoryName(oDoc.FullFileName) & "\" oChartDesc.ReplaceReference(orientChartPath & orientChartName) oChart.Update 'I've Also tried: oChart.AddLink(orientChartPath & orientChartName) but it always errors
Hi,
I gave a small test in 2014. It works well. The test video is at:
I have not 2013 installed at this moment. But if you think I did not miss anything to reproduce your problem, I can try to find a 2013 to test.
The VBA code I used is as below:
Public Sub test() Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument Dim oCTable As CustomTable Set oCTable = oDoc.SelectSet(1) Call oCTable.ReferencedDocumentDescriptor.ReplaceReference("c:\temp\book22222222.xlsx") End Sub
I can not replace the reference to the table. I watched in debug mode: for the ReferenceDocumentDescriptor reports an Unrecognized error. How can this problem be solved?
If I perform a replacement in a separate Sub, then the ReferenceDocumentDescriptors exists and the replacement is performed well.
But if this code is part of a large Sub, then the ReferenceDocumentDescriptors come with an unidentified error and you can not replace the reference.
How to find out why the error appears in:
Dim sSheet As Sheet sSheet = oDoc.Sheets.Item(1) Dim oCTable As CustomTable oCTable = sSheet.CustomTables.Item(1) Call oCTable.ReferencedDocumentDescriptor.ReplaceReference...