Hello
Here's my problem, I created a macro to save a Solidworks BOM as an Excel file. Everything works perfectly except that the Excel table created from the nomenclature in question has 2 additional columns at the end of the table. One QTE column and one Part Number column.
I can't figure out where the problem comes from.
Knowing that when I manually do the manipulation of saving the bill of materials in Excel, the 2 columns are not created.
For information, I don't know much about code, it's mostly ^^ resourcefulness.
If you have any ideas, I'm all for it.
Here is the code in question:
and for the backup part of the Excel file here is the code:
Status = swTable.SaveAsExcel(stDestinationFolder & stFileName & ".xlsx", True, False)
Thanks in advance
Maybe it comes from 2 columns hidden in your table?
Or the table template template used by default?
Edit: see this link in the lower part:
https://help.solidworks.com/2022/english/api/sldworksapi/Save_Table_to_Microsoft_Excel_Example_VB.htm?verRedirect=1
or it's well specified:
Edit2: there are tags for the code:
It's easier than an image because the code can be copied and pasted.
Thank you for such a quick response.
The strange thing is that when I manually save the BOM in Excel format, these columns don't exist. That's why for me the problem came from the macro.
I checked in the nomenclature on Solidworks (right click show column), no column is hidden.
Indeed I'm going to use the tags =)
Indeed, by modifying the SaveAsExcel formula by excluding hidden cells it works; the table saved in Excel format no longer has the 2 columns in question.
I don't know where these famous hidden columns come from but my problem is solved.
Thank you very much =D
Can you share the code for a future interested party?
And don't forget to put the subject as resolved.
The code in question:
Dim swApp As SldWorks.SldWorks
Dim swModDoc As SldWorks.IModelDoc2
Dim swTable As SldWorks.ITableAnnotation
Set swApp = Application.SldWorks
Set swModDoc = swApp.ActiveDoc
Dim swSM As ISelectionMgr
Set swSM = swModDoc.SelectionManager
Set swTable = swSM.GetSelectedObject6(1, -1)
swModDoc.ClearSelection2 (True)
Dim swSpecTable As IBomTableAnnotation
Set swSpecTable = swTable
The recording part:
Status = swSpecTable.SaveAsExcel(stDestinationFolder & stFileName & ".xlsx", False, False)
Thanks again