<?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 Export Parts List to Excel [VBA] in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165110#M69249</link>
    <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I stumbled upon a VBA code to export a parts list to excel, using the iLogic Interop.excel reference.&lt;/P&gt;&lt;P&gt;The code is really good, and I adjusted it to my needs, but there is one thing I can't figure out how to change.&lt;/P&gt;&lt;P&gt;I need to export the parts list as it is, but not including the first column.&lt;/P&gt;&lt;P&gt;I should include that the macro uses a company template.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My parts list in the drawing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My parts list on the drawing." style="width: 700px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701340i4273316F9AB2F50D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_3.png" alt="My parts list on the drawing." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;My parts list on the drawing.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Outcome of the macro:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Result of the current macro." style="width: 773px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701338i85DBA96E5E8F50D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_1.png" alt="Result of the current macro." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Result of the current macro.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want from the macro:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="What i want from the macro." style="width: 774px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701339i204D173F0474AFEB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_2.png" alt="What i want from the macro." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;What i want from the macro.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;PRE&gt;AddReference "Microsoft.Office.Interop.Excel"

Dim oExcel As New Microsoft.Office.Interop.Excel.Application

' For debugging
'oExcel.Visible = True

'get PDF target folder path
ooFolder = ThisDoc.PathAndFileName

'get drawing name
oName = ThisDoc.FileName

'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(ooFolder) Then
    System.IO.Directory.CreateDirectory(ooFolder)
End If

Dim oWB As Object
oWB = oExcel.Workbooks.Open("Z:\MecanicaDoc\MEC_PROJ\Requisição Interna XXXxx.xxxx.xlsm")

Dim oWS As Object
oWS = oWB.ActiveSheet

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

' Export the first PartsList
Dim oPL As PartsList
oPL = oSheet.PartsLists(1)

' Starting cell position on the Excel sheet
Dim iRowStart As Integer: iRowStart = 9
Dim iColStart As Integer: iColStart = 1

' Export headers
Dim iRow As Integer: iRow = iRowStart
Dim iCol As Integer: iCol = iColStart
Dim oCol As PartsListColumn
For Each oCol In oPL.PartsListColumns
  oWS.Cells(iRow, iCol).Value = oCol.Title
  iCol = iCol + 1
Next
iRow = iRow + 1

' Export content
Dim oRow As PartsListRow
For Each oRow In oPL.PartsListRows
  iCol = iColStart
  Dim oCell As PartsListCell
  For Each oCell In oRow
    oWS.Cells(iRow, iCol).Value = oCell.Value
    iCol = iCol + 1
  Next
  iRow = iRow + 1
Next


'For Each oCell In oPL.PartsListColumns
'	oWS.Cells(iRow, iCol).Value = ""
'	iRow = iRow + 1
'Next

' Save it
' We disable the confirmation dialog
' in case the file already exists and
' needs to be overwritten
oExcel.DisplayAlerts = False
Call oWB.SaveAs(ooFolder &amp;amp; "\" &amp;amp; oName &amp;amp; ".xlsm")

' Close excel
Call oExcel.Quit&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Mon, 25 Nov 2019 10:35:20 GMT</pubDate>
    <dc:creator>JoãoASilva</dc:creator>
    <dc:date>2019-11-25T10:35:20Z</dc:date>
    <item>
      <title>Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165110#M69249</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I stumbled upon a VBA code to export a parts list to excel, using the iLogic Interop.excel reference.&lt;/P&gt;&lt;P&gt;The code is really good, and I adjusted it to my needs, but there is one thing I can't figure out how to change.&lt;/P&gt;&lt;P&gt;I need to export the parts list as it is, but not including the first column.&lt;/P&gt;&lt;P&gt;I should include that the macro uses a company template.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My parts list in the drawing:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="My parts list on the drawing." style="width: 700px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701340i4273316F9AB2F50D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_3.png" alt="My parts list on the drawing." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;My parts list on the drawing.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Outcome of the macro:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Result of the current macro." style="width: 773px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701338i85DBA96E5E8F50D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_1.png" alt="Result of the current macro." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Result of the current macro.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want from the macro:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="What i want from the macro." style="width: 774px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701339i204D173F0474AFEB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_2.png" alt="What i want from the macro." /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;What i want from the macro.&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code:&lt;/P&gt;&lt;PRE&gt;AddReference "Microsoft.Office.Interop.Excel"

Dim oExcel As New Microsoft.Office.Interop.Excel.Application

' For debugging
'oExcel.Visible = True

'get PDF target folder path
ooFolder = ThisDoc.PathAndFileName

'get drawing name
oName = ThisDoc.FileName

'Check for the PDF folder and create it if it does not exist
If Not System.IO.Directory.Exists(ooFolder) Then
    System.IO.Directory.CreateDirectory(ooFolder)
End If

Dim oWB As Object
oWB = oExcel.Workbooks.Open("Z:\MecanicaDoc\MEC_PROJ\Requisição Interna XXXxx.xxxx.xlsm")

Dim oWS As Object
oWS = oWB.ActiveSheet

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

' Export the first PartsList
Dim oPL As PartsList
oPL = oSheet.PartsLists(1)

' Starting cell position on the Excel sheet
Dim iRowStart As Integer: iRowStart = 9
Dim iColStart As Integer: iColStart = 1

' Export headers
Dim iRow As Integer: iRow = iRowStart
Dim iCol As Integer: iCol = iColStart
Dim oCol As PartsListColumn
For Each oCol In oPL.PartsListColumns
  oWS.Cells(iRow, iCol).Value = oCol.Title
  iCol = iCol + 1
Next
iRow = iRow + 1

' Export content
Dim oRow As PartsListRow
For Each oRow In oPL.PartsListRows
  iCol = iColStart
  Dim oCell As PartsListCell
  For Each oCell In oRow
    oWS.Cells(iRow, iCol).Value = oCell.Value
    iCol = iCol + 1
  Next
  iRow = iRow + 1
Next


'For Each oCell In oPL.PartsListColumns
'	oWS.Cells(iRow, iCol).Value = ""
'	iRow = iRow + 1
'Next

' Save it
' We disable the confirmation dialog
' in case the file already exists and
' needs to be overwritten
oExcel.DisplayAlerts = False
Call oWB.SaveAs(ooFolder &amp;amp; "\" &amp;amp; oName &amp;amp; ".xlsm")

' Close excel
Call oExcel.Quit&lt;/PRE&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 10:35:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165110#M69249</guid>
      <dc:creator>JoãoASilva</dc:creator>
      <dc:date>2019-11-25T10:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165267#M69250</link>
      <description>&lt;P&gt;This could be an option:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; If OInvdrawdoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
            Dim oSheet As Inventor.Sheet
            oSheet = OInvdrawdoc.Sheets.Item(1)

            Dim strFileNameNoExt As String = System.IO.Path.GetFileNameWithoutExtension(OInvdrawdoc.FullFileName)


            Dim opl As PartsList

            If oDrawSheet.PartsLists.Count = 0 Then
                Exit Sub
            End If

            opl = oDrawSheet.PartsLists.Item(1)

            Dim oOptions As NameValueMap
            oOptions = AppInventor.TransientObjects.CreateNameValueMap 

            oOptions.Value("StartingCell") = "a1"
            oOptions.Value("ExportedColumns") = "QTY;UNID;DESCRIPTION;VENDOR;PART NUMBER;FABRICANTE"
            oOptions.Value("Template") = "Template file location"
            oOptions.Value("ApplyCellFormatting") = True
            oOptions.Value("ForceCellToText") = False

            oXlsExportFilePath = WriteToDirectoryNamePartlist &amp;amp; "\_Xls\" &amp;amp; strFileNameNoExt &amp;amp; " (PART-LIST).xls"

            Dim Informatie As FileInfo
            Informatie = New FileInfo(oXlsExportFilePath)

            If System.IO.File.Exists(oXlsExportFilePath) Then
                Informatie.IsReadOnly = False
                Kill(oXlsExportFilePath)
                opl.Export(oXlsExportFilePath, PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
            Else

                opl.Export(oXlsExportFilePath, PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
            End If
   
End if

        Exit Sub

    End Sub&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2019 12:20:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165267#M69250</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-11-25T12:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165535#M69251</link>
      <description>&lt;P&gt;I had a piece of code similar to that one, but it stopped working, so I had to find another way.&lt;/P&gt;&lt;P&gt;The code I provided works almost perfectly, but to make it work exactly like I want, probably needs a lot of changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What did you define "FileInfo" as?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:21:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165535#M69251</guid>
      <dc:creator>JoãoASilva</dc:creator>
      <dc:date>2019-11-25T14:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165576#M69252</link>
      <description>&lt;P&gt;System.IO.fileinfo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim Informatie As System.IO.FileInfo
            Informatie = New System.IO.FileInfo(oXlsExportFilePath)&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Nov 2019 14:43:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165576#M69252</guid>
      <dc:creator>bradeneuropeArthur</dc:creator>
      <dc:date>2019-11-25T14:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165889#M69253</link>
      <description>&lt;P&gt;Unfortunately, no sucess!&lt;/P&gt;&lt;P&gt;Same error as before:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot_4.png" style="width: 530px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/701462i629595B5A1863AAF/image-dimensions/530x294?v=v2" width="530" height="294" role="button" title="Screenshot_4.png" alt="Screenshot_4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;"O parâmetro está incorreto" &amp;gt; "The parameter is incorrect"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That's the reason I'm triyng to switch to VBA, to see if I can achieve the same results I had before.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Nov 2019 16:57:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9165889#M69253</guid>
      <dc:creator>JoãoASilva</dc:creator>
      <dc:date>2019-11-25T16:57:27Z</dc:date>
    </item>
    <item>
      <title>Re: Export Parts List to Excel [VBA]</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9207749#M69254</link>
      <description>&lt;P&gt;Your code is working smooth and perfect. I took my template and save as xlsm in temp folder just for testing. I tried with couple parts list and working with all of them same. Without parts list in drawing will be error. Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2019 18:24:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-parts-list-to-excel-vba/m-p/9207749#M69254</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-12-17T18:24:30Z</dc:date>
    </item>
  </channel>
</rss>

