BOM Export to Excel

BOM Export to Excel

KobusE
Advocate Advocate
705 Views
2 Replies
Message 1 of 3

BOM Export to Excel

KobusE
Advocate
Advocate

Good day,

Trying my hand at iLogics to export my BOM to Excel, just to use it as a table in my drawings - want to be able to set lineweights to suit my drawing style which one cannot do with the standard BOM table.

 

So I came accross some iLogic code from AU2020 by Carl Smith and Randy Mabery where they do this bit of coding. However, I must be doing something wrong as I get an error message as shown below....

KobusE_0-1629715568289.png

 

The code courtesy of their video, is:

 

Dim sFilename As String = String.Concat(ThisDoc.PathAndFileName(False),".xlsx")
ThisBOM.Export("Parts Only", "fileName", kMicrosoftExcelFormat)
'kMicrosoftAccessFormat			= Microsoft Access
'kMicrosoftExcelFormat			= Microsoft Excel
'kdBASEIIIFormat			= dBASE III
'kdBASEIVFormat				= dBASE IV
'kTextFileTabDelimitedFormat		= Text File Tab Delimited
'kTextFileCommaDelimitedFormat		= Text File Comma Delimited
'kUnicodeTextFileTabDelimitedFormat	= Unicode Text File Tab Delimited
'kUnicodeTextFileCommaDelimitedFormat	= Unicode Text File Comma Delimited

 Anyone that can pick up where I go wrong?

 

Regards

 

Kobus

0 Likes
Accepted solutions (1)
706 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @KobusE.  I the variable you created in the first line ("sFilename"), to store the file name is not being used in the second line.  In the second line you are using "fileName".  Replace "fileName" in that second line with the unquoted sFilename variable, that you created in the first line.  You never put quotes around the name of a variable.  A variable is an object that you created and gave a value to.  When you put that variable into the second line, it will be representing the value you gave it in the first line.

So your code should look like this:

 

 

Dim sFilename As String = String.Concat(ThisDoc.PathAndFileName(False),".xlsx")
ThisBOM.Export("Parts Only", sFilename, FileFormatEnum.kMicrosoftExcelFormat)

 

 

You may also notice that I slightly modified the input specification at the end of that second line too.  This is not necessary, but I just wanted you to notice that when dealing with an 'Enum', you can type in the base part of the Enum, followed by the (.) dot, then intellisense will show you the available options within that Enum, for you to choose from.  This is often a good practice when you are just getting started, so you know later where you got that value from.  Here is the link to the online help page for that specific iLogic method ThisBOM.Export().

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

KobusE
Advocate
Advocate

Good morning,

Awesome, I tested it after making the changes and it works like a charm. Thanks for your mentoring, much appreciated.

 

Regards

 

Kobus

0 Likes