- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Been working on writing an iLogic script for a number of hours now and tried googling but couldn't find anyone who has exported their assembly and sub-assembly BOMs via the same iLogic script and at this point I'm stumped
Tried to write the simplest script I could to accomplish this however I get an error on the ActiveDocument and pretty much can't go any further. I've tried writing the loop about 10 different ways using ThisDoc.Document to keep the top level document while re-defining the active document, or continually trying to redefine what is the current active document, or opening the refdoc...just can't get anything to work and seeing if someone might know what the solution to this is
Sub Main()
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim refDocs As Document = ThisDoc.Document
Dim refDoc As Document
Dim projectNumber As String = Left(oDoc.DisplayName, 4)
Dim oFolder As String = System.Environment.GetFolderPath(Desktop) & "\Export BOMs\" & projectNumber & "\"
Call ExportBom(oDoc, oFolder)
For Each refDoc In refDocs.AllReferencedDocuments
If refDoc.DocumentType = kAssemblyDocumentObject Then
refDoc.Activate
Call ExportBom(oDoc, oFolder)
End If
Next
End Sub
Function ExportBom(oDoc As Document, oFolder As String)
Dim oPath As String = oFolder & oDoc.DisplayName & ".xls"
ThisBOM.Export("Structured", oPath, kMicrosoftExcelFormat)
End Function
Solved! Go to Solution.