Macro

Hello

I try to make a macro to facilitate a task that we often do to demine the size of the standard parts we create.

These are the steps to follow, I send you below the description of these tasks for a better understanding:

1) Open the SOLIDWORKS file
2) Open the room family in a new window
3) Save the excel file
4) Close the Excel file
5) Delete the Part Family in SOLIDWORKS
6) Delete Configurations
7) Uncheck the option "link display states to config"
8) Save the SOLIDWORKS file
9) Recreate the part family (insert\tables\Part family)
10) Check the "From File" option and tell it the Excel file you previously saved.
11) Redo Publisher
12) Save the file.

No problem is launched during the recording, until the exusion where the macro freezes at the level of closing the Excel file, (image below)

anyone have any idea how I can solve this problem, I would be very grateful if you could help me:)

I hope I was clear enough

Thank you in advance.

Hello

Send us a text file with the code or the .swp file. Because the text of your question is illegible.

@+.

 

Editing: What is the error message?

1 Like

In fact this line is not necessary because it is already two lines higher, so I think we can delete it.

Does it work?

Edit: the part family is already closed when there is this error?

Thank you Remrem and PL for your feedback 

Attached is the .swp file you requested remrem, 

PL, I tried deleting all the lines that contain the closure of the file but it doesn't work it blocks in the following line,

By the way I just noticed something in the macro file, it's that I have to make a file for each component (nut, screws ...) because in the step  where you have to select and delete the configs there is a description of the name of the config (e.g. medium cs washer M 12 .. ) , I tried to delete the description (example:  boolstatus = Part.Extension.SelectByID2("Convex washer C  M30 CL4 (SP01033520A)", "CONFIGURATIONS", 0, 0, 0, True, 0, Nothing, 0) 

and replace it with:  boolstatus = Part.Extension.SelectByID2  )

so that I use a single macro to tt the files.

any idea!?  

Thank you in advance


t1.swp

No, you shouldn't delete all the lines, only the second time it appears in yellow in the question image.

Do you know VBA programming for SolidWorks or VBA for short?

Because there is a lot of work! Indeed, you can't just save this type of macro to use it on all files (as for the name of the configurations), you have to loop on all the configurations.

See my tutorials that loop on all the configurations for inspiration:

http://www.lynkoa.com/tutos/3d/enregistrer-une-piece-chaque-configuration

http://www.lynkoa.com/tutos/solidworks/macro-pour-toutes-les-configurations-d-un-assemblage-pour-activer-l-option-%E2%80%9Cpromouv

1 Like

Ah ok, and I thought it's easy to do, I'm going to read the tutorials you sent me PL and try to apply them

Thank you