<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ThisBOM .export column order problem. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7249531#M125509</link>
    <description>&lt;P&gt;From Curtis' code it looks like you'll just have to add a third parameter to the &lt;STRONG&gt;Export&lt;/STRONG&gt; function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;oOptions&lt;/STRONG&gt; = ThisApplication.TransientObjects.CreateNameValueMap


'specify an existing template file
'to use For formatting colors, fonts, etc

&lt;STRONG&gt;oOptions&lt;/STRONG&gt;.Value("Template") = "C:\Temp\PartListExport.xls"
oStructuredBOMView.Export (oExportName &amp;amp; ".xlsx", kMicrosoftExcelFormat, &lt;STRONG&gt;oOptions&lt;/STRONG&gt;)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Cheers,&lt;/P&gt;</description>
    <pubDate>Mon, 24 Jul 2017 14:31:24 GMT</pubDate>
    <dc:creator>adam.nagy</dc:creator>
    <dc:date>2017-07-24T14:31:24Z</dc:date>
    <item>
      <title>ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4902030#M125492</link>
      <description>&lt;P&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;&lt;FONT face="Calibri"&gt;I have an iLogic routine using the ThisBOM.export function.&amp;nbsp; I am using the “parts only” format for my export.&amp;nbsp; The format that ends up in my excel file has the columns in alphabetical order based on the column header.&amp;nbsp;&amp;nbsp;&amp;nbsp;This is different than the layout in the part only view.&amp;nbsp; What drives the column order in the ThisBOM function and can it be altered or controlled? Thanks&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2014 19:53:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4902030#M125492</guid>
      <dc:creator>tdipilla</dc:creator>
      <dc:date>2014-03-21T19:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4947146#M125493</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I seem to remember that the order in the UI and through the API are not kept in sync. This thread says it too:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://208.74.205.69/t5/Inventor-Customization/Export-Structured-BOM-view-with-All-Levels/td-p/3737084" target="_self"&gt;http://208.74.205.69/t5/Inventor-Customization/Export-Structured-BOM-view-with-All-Levels/td-p/3737084&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can do some sorting on the BOMView, but that as well might not be refelected back in the UI - it should have an effect on the Export function though.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2014 20:30:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4947146#M125493</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2014-04-09T20:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4948838#M125494</link>
      <description>I had a similar issue - exporting the structured view. Seems no matter what I did it always came out sorted by the model view tab. Turns out as of 2013 it was a bug in the SDK and someone else had reported it as well. I was supposed added to the list to be informed about updates on it but i've not heard anything. Of course that's just been about 2 months and they've been wrapping up 2015 in that time frame so I don't read much into no hearing anything yet.</description>
      <pubDate>Thu, 10 Apr 2014 13:42:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4948838#M125494</guid>
      <dc:creator>mslosar</dc:creator>
      <dc:date>2014-04-10T13:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4948900#M125495</link>
      <description>&lt;P&gt;&lt;SPAN style="line-height: 15px;"&gt;Hi,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="line-height: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Did you get the change request ID of that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Adam&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 13:56:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4948900#M125495</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2014-04-10T13:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4949348#M125496</link>
      <description>&lt;P&gt;Thankyou for the input.&amp;nbsp; I ended up just running a sort routines in the ilogic routine i have to format the final spreadsheet as required.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Apr 2014 15:58:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/4949348#M125496</guid>
      <dc:creator>tdipilla</dc:creator>
      <dc:date>2014-04-10T15:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7054285#M125497</link>
      <description>&lt;P&gt;HI&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you advise how to do the sort routine on the created excel file.&amp;nbsp;I am having the same issue where BOM is exported but excel columns are sorted alphabetically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bryan&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 05:27:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7054285#M125497</guid>
      <dc:creator>mcloughlin_b</dc:creator>
      <dc:date>2017-05-02T05:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7056018#M125498</link>
      <description>&lt;P&gt;Depending on how you are doing it... the attached code is VBA to reorder columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;It must have xlws set beforehand as a global variable.&lt;/LI&gt;
&lt;LI&gt;It also only sorts if the data is on the first row.&lt;/LI&gt;
&lt;LI&gt;You can change array to make it sort by a different order.&lt;/LI&gt;
&lt;LI&gt;Words used in the array must match what is in the excel file.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Private Sub ReorderXLBOM()
    Dim arrColOrder
    Dim ndx
    Dim Found
    Dim counter

    arrColOrder = Array("Item", "QTY", "Part Number", "Description", "Stock Number")
    counter = 1

On Error Resume Next

    For ndx = LBound(arrColOrder) To UBound(arrColOrder)

        'Set Found = xlws.Rows("1:1").Find(arrColOrder(ndx),, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
        Set Found = xlws.Rows("1:1").Find(arrColOrder(ndx), , -4163, 1, 2, 1, False)
    
        If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Error With Excel FIND function: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
        End If

        If Not Found Is Nothing Then
                If Found.Column &amp;lt;&amp;gt; counter Then
                        Found.EntireColumn.Cut
                        xlws.Columns(counter).Insert -4161
                        Application.CutCopyMode = False
                End If
                counter = counter + 1
        End If
    Next
    
    If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Reorder Columns Rule Error: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
    End If   
End Sub&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2017 17:20:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7056018#M125498</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-05-02T17:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7060365#M125499</link>
      <description>&lt;P&gt;Hi Justin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My coding prowess is sketchy at best so can you please have a squizz at my code and advise how to add your VBA in to achieve the objective. The code is ilogic&amp;nbsp;which I have pieced together.&amp;nbsp;I basically import a custom BOM into the assembly (which has the columns as required) then export. I'm sure there is a more efficient way but it works, excepting for the reordering of columns.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks for your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bryan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SyntaxEditor Code Snippet&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Imports&lt;/SPAN&gt; &lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Windows&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Forms&lt;/SPAN&gt;
&lt;SPAN&gt;Imports&lt;/SPAN&gt; &lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;IO&lt;/SPAN&gt;

&lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; Get the active assembly&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;AssemblyDocument&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;set  a reference to the BOM&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oBOM&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;BOM&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;BOM&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Get user path for custom BOM&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt;
    &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; Search for the folder&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;Dialog&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;New&lt;/SPAN&gt; &lt;SPAN&gt;FolderBrowserDialog&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;
    &lt;SPAN&gt;Dialog&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ShowNewFolderButton&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;True&lt;/SPAN&gt;
    &lt;SPAN&gt;Dialog&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Description&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Choose Custom BOM Folder&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;

    &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; Show dialog box&lt;/SPAN&gt;
    &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;DialogResult&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;OK&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Dialog&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ShowDialog&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
        &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; User clicked 'ok' on dialog box - capture the export path&lt;/SPAN&gt;
        &lt;SPAN&gt;oPath&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Dialog&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;SelectedPath&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;
    
    &lt;SPAN&gt;Else&lt;/SPAN&gt;
        &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; User clicked 'cancel' on dialog box - exit&lt;/SPAN&gt;
        &lt;SPAN&gt;Return&lt;/SPAN&gt;
    &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;import custom BOM&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;ofilename&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;assume filename exists&lt;/SPAN&gt;
&lt;SPAN&gt;ofilename&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;oPATH&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BRUCE EXPORT.xml&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Show&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Custom BOM is:&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;ofilename&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Title&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;Call&lt;/SPAN&gt; &lt;SPAN&gt;oBom&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;ImportBOMCustomization&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ofilename&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;set the structured view to 'all levels'&lt;/SPAN&gt;
&lt;SPAN&gt;oBOM&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;StructuredViewFirstLevelOnly&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;False&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; Make sure that the structured view is enabled.&lt;/SPAN&gt;
&lt;SPAN&gt;oBOM&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;StructuredViewEnabled&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;True&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;set a reference to the "Structured" BOMView&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oStructuredBOMView&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;BOMView&lt;/SPAN&gt;
&lt;SPAN&gt;oStructuredBOMView&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;oBOM&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;BOMViews&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Item&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Structured&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;End Sub&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt; Export the BOM view to an Excel file&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;ExportPath&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Path&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oExportName&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;FileName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;without extension&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;get BOM Target folder path&lt;/SPAN&gt;
&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;String&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;Strings&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Left&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ExportPath&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;InStrRev&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;ExportPath&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;BOM&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;
&lt;SPAN&gt;MessageBox&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Show&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Export Path is:&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Title&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Check for the BOM folder and create it if it does not exist&lt;/SPAN&gt;
 &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Not&lt;/SPAN&gt; &lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;IO&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Directory&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Exists&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
         &lt;SPAN&gt;System&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;IO&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Directory&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;CreateDirectory&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
 &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;
 &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;check For existing XLSX file And delete it If found&lt;/SPAN&gt;
            &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Dir&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBom&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;oExportName&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;.xlsx&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt; &lt;SPAN&gt;&amp;lt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN&gt;""&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
            &lt;SPAN&gt;Kill&lt;/SPAN&gt; &lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBom&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;oExportName&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;.xlsx&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
                &lt;SPAN&gt;Else&lt;/SPAN&gt;
            &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt; 

&lt;SPAN&gt;oStructuredBOMView&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Export&lt;/SPAN&gt; &lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;oExportName&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;.xlsx&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;kMicrosoftExcelFormat&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;define Excel Application object&lt;/SPAN&gt;
&lt;SPAN&gt;excelApp&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;CreateObject&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Excel.Application&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;set Excel to run visibly&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;change to false if you want to run it invisibly&lt;/SPAN&gt;
&lt;SPAN&gt;excelApp&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Visible&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;True&lt;/SPAN&gt;

&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;open the workbook&lt;/SPAN&gt;
&lt;SPAN&gt;wb&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;excelApp&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Workbooks&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Open&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;oFolderBOM&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;oExportName&lt;/SPAN&gt; &lt;SPAN&gt;&amp;amp;&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;.xlsx&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;set all of the columns to autofit&lt;/SPAN&gt;
&lt;SPAN&gt;excelApp&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Columns&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;AutoFit&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;suppress prompts (such as the compatibility checker)&lt;/SPAN&gt;
&lt;SPAN&gt;excelApp&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;DisplayAlerts&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;False&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;save the workbook&lt;/SPAN&gt;
&lt;SPAN&gt;wb&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Save&lt;/SPAN&gt;

&lt;SPAN&gt;End Sub&lt;/SPAN&gt;
&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;close the workbook, uncomment if you want to close the xls file at the end&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;wb.Close&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 04:51:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7060365#M125499</guid>
      <dc:creator>mcloughlin_b</dc:creator>
      <dc:date>2017-05-04T04:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7062210#M125500</link>
      <description>&lt;P&gt;Here is a heavily reworked version of your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note, the intent is for the BOM customization to be located in one location and then just imported from there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that the BOM order is set by an array of strings that corresponds to the column titles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;AddReference "Microsoft.Office.Interop.Excel" 'To use excel

Imports System.Windows.Forms
Imports System.IO
Imports Microsoft.Office.Interop.Excel        'To use excel

Sub Main()
	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	
	'Dim oPath As String
	'oPath = oFolderDlg
	'oFileName = oPath &amp;amp; "Bruce.xml"
	
	ExportBOM(oDoc)
End Sub

Private BOMCustomizationFile As String = "C:\CustFile.xml"

Private excelApp As Microsoft.Office.Interop.Excel.Application
Private xlws As Worksheet

Sub ExportBOM(oDoc As Document)

'File Path Creation/Processing
	'Note, the following line will cause an error if the document is not saved.
	Dim oExportPath As String = System.IO.Path.GetDirectoryName(oDoc.FullFileName) &amp;amp; "\BOM\"
	Dim oExportName As String = oExportPath &amp;amp; System.IO.Path.GetFileNameWithoutExtension(oDoc.FullFileName) 'without extension'get BOM Target folder path
	
	If Not System.IO.Directory.Exists(oExportPath) Then: System.IO.Directory.CreateDirectory(oExportPath): End If

	If Dir(oExportName &amp;amp; ".xlsx") &amp;lt;&amp;gt; "" Then
		Kill (oExportName &amp;amp; ".xlsx")
	End If 

'Inventor BOM Processing
	Dim oBOM As BOM = oDoc.ComponentDefinition.BOM

	oBOM.ImportBOMCustomization(BOMCustomizationFile)
	oBOM.StructuredViewEnabled = True
	oBOM.StructuredViewFirstLevelOnly = False
	
	Dim oStructuredBOMView As BOMView
	oStructuredBOMView = oBOM.BOMViews.Item("Structured")
	oStructuredBOMView.Export (oExportName &amp;amp; ".xlsx", kMicrosoftExcelFormat)
	
'Excel processing
	excelApp = CreateObject("Excel.Application")
	excelApp.Visible = True
	excelApp.DisplayAlerts = False
	
	wb = excelApp.Workbooks.Open(oExportName &amp;amp; ".xlsx")
	xlws = wb.Worksheets(1)
	
	Call ReorderXLBOM()
	
	excelApp.Columns.AutoFit
	excelApp = Nothing

End Sub

Private Sub ReorderXLBOM()
    Dim ndx As Integer
    Dim Found As Range
    Dim counter As Integer = 1
	
	Dim arrColOrder() As String = {"Item", "QTY", "Part Number", "Description", "Stock Number"}
    'arrColOrder = Array("Item", "QTY", "Part Number", "Description", "Stock Number")

	On Error Resume Next

    For ndx = LBound(arrColOrder) To UBound(arrColOrder)

        'Set Found = xlws.Rows("1:1").Find(arrColOrder(ndx),, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
        Found = xlws.Rows("1:1").Find(arrColOrder(ndx), , -4163, 1, 2, 1, False)
    
        If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Error With Excel FIND function: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
        End If

        If Not Found Is Nothing Then
                If Found.Column &amp;lt;&amp;gt; counter Then
                        Found.EntireColumn.Cut
                        xlws.Columns(counter).Insert(-4161)
                        excelApp.CutCopyMode = False
                End If
                counter = counter + 1
        End If
    Next
    
    If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Reorder Columns Rule Error: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
    End If   
End Sub

Public Function oFolderDlg
    Dim dialog = New FolderBrowserDialog()
'    dialog.SelectedPath = Application.StartupPath
	dialog.ShowNewFolderButton = True
'	openFileDialog1.InitialDirectory 
    If DialogResult.OK = dialog.ShowDialog() Then
        oPath = dialog.SelectedPath
	Else
		MsgBox("No File Selected. Aborting Rule")
		oPath = ""
    End If
	Return oPath
End Function&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 May 2017 17:33:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7062210#M125500</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-05-04T17:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7063782#M125501</link>
      <description>&lt;P&gt;Hi Justin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's genius, many thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bryan&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 09:26:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7063782#M125501</guid>
      <dc:creator>mcloughlin_b</dc:creator>
      <dc:date>2017-05-05T09:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7071473#M125502</link>
      <description>&lt;P&gt;Brilliant code, I want to give you kudo's but I can click on the button all I want, nothing works (im signed in)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Ok, I had to click the icon, not the text, even though it looks like you can also click on the text. First time that has me fooled&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 11:29:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7071473#M125502</guid>
      <dc:creator>Cadkunde.nl</dc:creator>
      <dc:date>2017-05-09T11:29:02Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7241983#M125503</link>
      <description>&lt;P&gt;I get this error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Excel cannot open the file 'A00001.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What am I missing?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 13:43:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7241983#M125503</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-20T13:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242072#M125504</link>
      <description>&lt;P&gt;Maybe &lt;STRONG&gt;Inventor 2015&lt;/STRONG&gt; can only save to &lt;STRONG&gt;xls&amp;nbsp;&lt;/STRONG&gt;and not &lt;STRONG&gt;xlsx&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;Try renaming the file to &lt;STRONG&gt;xls&lt;/STRONG&gt; and open it in &lt;STRONG&gt;Excel&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 14:08:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242072#M125504</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2017-07-20T14:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242223#M125505</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/339467"&gt;@adam.nagy&lt;/a&gt;&amp;nbsp;thanks Adam, that did the trick!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 14:42:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242223#M125505</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-20T14:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242460#M125506</link>
      <description>&lt;P&gt;How possible is it to modify this create from an&amp;nbsp;existing XLS template instead?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:45:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242460#M125506</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-20T15:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242489#M125507</link>
      <description>&lt;P&gt;If you simply mean making the above code work with &lt;STRONG&gt;XLS&lt;/STRONG&gt;, then you just have to replace all the&amp;nbsp;&lt;STRONG&gt;".xlsx"&lt;/STRONG&gt; strings with&amp;nbsp;&lt;STRONG&gt;".xls"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 15:55:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242489#M125507</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2017-07-20T15:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242522#M125508</link>
      <description>&lt;P&gt;No sorry, I did that and its working as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was wondering if its possible to adapt the code to use a pre-existing excel template&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Curtis' blog shows how to do it through a drawing part list:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://inventortrenches.blogspot.co.uk/2011/06/ilogic-export-parts-list-with-options.html" target="_blank"&gt;http://inventortrenches.blogspot.co.uk/2011/06/ilogic-export-parts-list-with-options.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I need a rule that will export all levels of the structured BOM (ideally to a template which will have my costing columns on it)&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 16:05:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7242522#M125508</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-07-20T16:05:44Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7249531#M125509</link>
      <description>&lt;P&gt;From Curtis' code it looks like you'll just have to add a third parameter to the &lt;STRONG&gt;Export&lt;/STRONG&gt; function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;STRONG&gt;oOptions&lt;/STRONG&gt; = ThisApplication.TransientObjects.CreateNameValueMap


'specify an existing template file
'to use For formatting colors, fonts, etc

&lt;STRONG&gt;oOptions&lt;/STRONG&gt;.Value("Template") = "C:\Temp\PartListExport.xls"
oStructuredBOMView.Export (oExportName &amp;amp; ".xlsx", kMicrosoftExcelFormat, &lt;STRONG&gt;oOptions&lt;/STRONG&gt;)
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Cheers,&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2017 14:31:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7249531#M125509</guid>
      <dc:creator>adam.nagy</dc:creator>
      <dc:date>2017-07-24T14:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7562271#M125510</link>
      <description>&lt;P&gt;It's really amazing how random that inventor excel export winds up, so I have reluctantly added MMM's column sorting code into my export "program":&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;'heavily reformat exported xls...
'On Error Resume Next
Set excel_app = CreateObject("Excel.Application")
'excel_app.Visible = True
excel_app.Workbooks.Open (bomname)
Dim rows As Integer
Dim rowbottom As String
rows = excel_app.ActiveSheet.UsedRange.rows.Count
rowbottom = "A1" &amp;amp; ":" &amp;amp; "A" &amp;amp; rows
excel_app.Range("A1").EntireColumn.Insert
excel_app.Range(rowbottom) = "=TRIM(LEFT(SUBSTITUTE(MID(CELL(""filename"",A1),FIND(""["",CELL(""filename"",A1))+1,255),"".xl"",REPT("" "",255)),255))"
excel_app.Range("F1").EntireColumn.Insert
excel_app.Range("F1") = "Assembly Qty"
excel_app.Range("A1") = "Order"

'try some sorting
Dim arrColOrder
    Dim ndx As Integer
    Dim Found As Range
    Dim counter As Integer
    arrColOrder = Array("Order", "Item", "Part Number", "BOM Structure", "QTY", "Assembly Qty", "A1 Router", "A1 Time", "B1 Laser", "B1 Time", "C1 Saw-AL", "C1 Time", "D1 Saw-ST", "D1 Time", "E1 C-Axis", "E1 Time", "F1 Machining", "F1 Time", "G1 Debur", "G1 Time", "H1 Brake", "H1 Time", "I1 Weld", "I1 Time", "J1 RWeld", "J1 Time", "K1 Assembly", "K1 Time", "L1 Outsource", "L1 Time", "M1 Ship", "Bulk", "Setup")
    counter = 1

On Error Resume Next

    For ndx = LBound(arrColOrder) To UBound(arrColOrder)

'was not successful setting global variable for worksheet, tried some bfi:

        'Set Found = Sheet1.rows("1:1").Find(arrColOrder(ndx), , LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
        Set Found = Sheet1.rows("1:1").Find(arrColOrder(ndx), , -4163, 1, 2, 1, False)

        If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Error With Excel FIND function: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
        End If

        If Not Found Is Nothing Then
                If Found.Column &amp;lt;&amp;gt; counter Then
                        Found.EntireColumn.Cut
                        xlws.Columns(counter).Insert -4161
                        Application.CutCopyMode = False
                End If
                counter = counter + 1
        End If
    Next

    If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Reorder Columns Rule Error: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
    End If

excelApp.Columns.AutoFit
excel_app.ActiveWorkbook.Save
excel_app.ActiveWorkbook.Close&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe if I roll back to xlws in this code instead of "Sheet1" and Public xlws as string, xlws = Sheet1, this would work, but I don't know where to declare these global variables!!&lt;BR /&gt;&lt;BR /&gt;When this runs at best, I get error with excel find 424: object required - obviously the arrayed names aren't being passed.&lt;BR /&gt;&lt;BR /&gt;I tried making a new otherwise empty module where I set xlws as a public string, that works, gets me a different error of invalid qualifier for the set found = xlws.rows line.&amp;nbsp; &amp;nbsp;I can&amp;nbsp;dim xlws as Sheet1 inside of the sub, get the same result.&lt;BR /&gt;&lt;BR /&gt;I'm sure I'll learn something from this...&amp;nbsp; Thanks everyone.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2017 15:43:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7562271#M125510</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-21T15:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: ThisBOM .export column order problem.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7562313#M125511</link>
      <description>&lt;P&gt;Try this instead:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Feed it the&amp;nbsp;worksheet you want to process&amp;nbsp;in the call in your code, DON'T modify the code aside from the 2 bolded sections; header row indicator, and the&amp;nbsp;array of the desired column order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Private Sub ReorderXLBOM(ByVal excelapp As Application, ByVal xlws As Worksheet)
    Dim ndx As Integer
    Dim Found As Range
    Dim counter As Integer = 1
	
	Dim arrColOrder() As String = {&lt;STRONG&gt;"Item", "QTY", "Part Number", "Description", "Stock Number"&lt;/STRONG&gt;}
    'arrColOrder = Array("Item", "QTY", "Part Number", "Description", "Stock Number")

	On Error Resume Next

    For ndx = LBound(arrColOrder) To UBound(arrColOrder)

        'Set Found = xlws.Rows("1:1").Find(arrColOrder(ndx),, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
        Found = xlws.&lt;STRONG&gt;Rows("1:1")&lt;/STRONG&gt;.Find(arrColOrder(ndx), , -4163, 1, 2, 1, False)
    
        If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Error With Excel FIND function: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
        End If

        If Not Found Is Nothing Then
                If Found.Column &amp;lt;&amp;gt; counter Then
                        Found.EntireColumn.Cut
                        xlws.Columns(counter).Insert(-4161)
                        excelApp.CutCopyMode = False
                End If
                counter = counter + 1
        End If
    Next
    
    If Err.Number &amp;lt;&amp;gt; 0 Then
            MsgBox ("Reorder Columns Rule Error: " &amp;amp; Err.Number &amp;amp; " :: " &amp;amp; Err.Description &amp;amp; vbLf &amp;amp; vbLf &amp;amp; ndx)
            Err.Clear
    End If   
End Sub&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Nov 2017 15:42:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/thisbom-export-column-order-problem/m-p/7562313#M125511</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2017-11-21T15:42:57Z</dc:date>
    </item>
  </channel>
</rss>

