Copy/paste Bill of Materials to Excel

Hello,

I wanted to know if it was possible to copy/paste part of the bill of materials from a plan to paste it into an Excel file? (without going through a "save as" of the bill of materials and create an Excel file)
Do you have a trick or is it not possible?

Thank you

Hello,

The kings of the macro will tell you that everything is possible (macro that saves in Excel export format and then copies the table to allow you to have it in your Windows copy/paste stack, then delete the file we just created).

Otherwise there doesn't seem to be a direct copy solution (in 2020 anyway).

Then you have the historical ' relou ' solution: you remove your SW nomenclature, you put an old nomenclature back in Excel format which can be edited by right-clicking in Excel → possible to copy it

2 Likes

Hello @Guillaume_REBOUSSIN

One question, why without saving as? It's a simple solution, which would suit you.

Indeed copy/paste does not work, only in the other direction (Excel to SW)

1 Like

@froussel

Because I have to extract a dozen nomenclatures to join them in the same excel file... so it would be much more practical to copy/paste

Hello,

In this case by macro, no other native solutions except the one offered by @froussel

1 Like

Extracting by macro (@Cyril_f ) and compiled by the same macro is possible it seems to me.
This is equivalent to a saved-under + file compilation.

1 Like

Hello,

Below is a rudimentary macro that copies the selected area of the BOM to the Windows clipboard (thanks to the AI...).
No multiple selections possible.

All that remains is to paste the result into Excel.

[Edit - Modified macro, available below]

Hello,
Without the AI, I already have an existing code to extract the data from a nomenclature line (I think I have already provided it for another request of the same type on this forum).
You can also manipulate Excel directly from the macro launched in SW and copy/paste directly without waiting for the user to intervene.

1 Like

Hello,
I take the opposite view, but we can consider assembling all the parts, even without positioning, and making a nomenclature.

Very good suggestion to @Cyril_f, copy/paste in a single macro from Solidworks.
Procedure:

  • In Excel, select the destination cell;
  • In Solidworks, select the BOM range to copy/paste;
  • Run the macro from Solidworks.

Confirmation is requested if the destination range in Excel is not empty.

StructureEiffel.swp (67 KB)

1 Like

Here is one of the topics for retrieving data from tables
Reading BOMs - Macro - myCAD Forum
And another one to export to Excel
Export Bill of Materials to Excel with a VBA Macro - Macro - myCAD Forum

1 Like

Hello,

In all these solutions, the problem of updating the bill of materials will remain in the event of a change in the assembly. So, advice remain vigilant

Hello,

Treatment can always be added to manage this case :slight_smile:

Data can be linked between Excel files to update automatically.
Excel will require you to enable binding updates, or update them manually.
The macro must create files for each nomenclature and then in a compilation file you update with each update.
I think you need to create a value in the SolidWorks BOM that can then be filtered later, either through the macro or through Excel, a date for example.
Is it possible :thinking:

Hi I had made this macro a while ago and I still use it.

You select a table, or a cell it doesn't matter, you launch the macro

and then you have more than a Ctrl+V in an Excel cell, that's it.

CopyBomToExcel.swp (48 KB)

2 Likes

In this case you create a temporary ASM with your 10 sets. You don't even need to create a plan, you can extract the complete BOM from the ASM.

1 Like

Hello @Ludovic_MARCELIN

I think you've solved his problem: all he has to do is assign the macro to a key or a personal icon and that's it.

After retesting your macro, the copy paste is bad for cells containing paragrpahe breaks: when pasting in Excel it cuts the data into several cells instead of making a cell with text containing paragraph breaks.

A VBA pro should easily be able to correct this detail

Here is a ' functional ' code that ' solves ' the problem of line breaks/paragraph breaks (in brute mode after editing the code by M365 Copilot: I replaced all the characters that looked like a paragraph/line break and replaced it with a space.
→ Text imports well into a single cell

On the other hand, there is no longer a referral :crying_cat_face:

CopyBomToExcel - Copilot edit.swp (48.5 KB)

If someone manages to make it cleaner (and manages to put line references inside the text of the excel cell) he just has to repost.

NB: not sure if this is feasible since the macro goes through a string separated by tabs (which offset the cells when copying in Excel) and CRLFs (which make the reference to the next line).
It would probably be necessary to completely rewrite the macro to have something really functional (that the macro creates a temporary Excel file, that pastes the text into the cells and that puts all the filled cells in the clipboard).

1 Like

Exactly, in this case, I didn't need it, all my values are on a single line in my BOMs