How to Resolve Runtime Error '91'?

Hello everyone,

 

Being in BTS Crsa, I have to make a configurable CAD of a conveyor (internship project).

I usually use Solid Edge but the company I'm in uses Solidworks, so I'm a bit lost.

The goal of this project is to be able to set the dimensions of a conveyor (length, width etc.) so I made a macro in excel by declaring solidworks etc. only there is not much that works. Not being used to doing this kind of work (I'm zero in vba!) I provide you with my macro with some indications so that you can clarify for me:

 

Sub Bouton_Clic()

 

Set swApp = CreateObject("Sldworks.Application")

Set Part = swApp.ActiveDoc

 

Part.Parameter("D1@Esquisse1@Longueur_convoyeur"). SystemValue = Range ("C2"). Value / 1000

Part.ClearSelection

Part.ForceRebuild

 

Part.Parameter("D1@Extru.-Mince1@Largeur_convoyeur"). SystemValue = Range ("C4"). Value / 1000

Part.ClearSelection

Part.ForceRebuild

 

End Sub

 

The error message is a runtime error '91' but I don't see what's wrong.

These are the "Part.Parameter... " which are highlighted.

"Longueur_convoyeur" and "Largeur_convoyeur" coincide with the name I gave in Excel.

 

I hope I have explained my problem well.

 

Thanks in advance

Hello

So in SolidWorks there is the notion of configuration (part family) to manage the different versions of a project (part or assembly). Configurations are created once your geometry is complete, and variables that need to change can be driven by an Excel spreadsheet printed in your SolidWorks document. These can be the dimensions, the properties, the status of deletion or not of the functions etc ... Take the time to consult the online help.

I think that going through a macro in Excel is a bit complicated! At least that's my opinion.

Kind regards

4 Likes

Runtime error "91" means that the object is not connected/populated... it is therefore empty

Obviously the names of the odds don't match...

put your document in peice attached that I check ...

 

 

 

5 Likes

Thank you for your answer jmsavoyat, one last little question:

So I just made an auto creation which adds a table in solidworks as you told me but I wanted to know if it wouldn't be a problem since I work directly on an assembly (in terms of constraints etc.)

 

Kind regards

Hello

 

There are several tutorials on part families on SolidWorks, for example these two:

 

http://www.lynkoa.com/store/fr/tutos-formations/tutos/thematiques-avancees-les-familles-de-pieces-dans-solidworks.html

 

http://www.lynkoa.com/store/fr/tutos-formations/formations/famille-de-pieces-solidworks.html

 

The families of parts (even if the name is misleading) work quite well in assemblies!

It is possible to process stresses, deletions of certain parts, stress distance values between parts, etc.

1 Like

A: Jfaradon

Here is the file (as I told you, I start being indulgent if possible!)


3217-1000_convoyeur_sortie_multivac2.xlsx

Problem for the attachment, I can't save it or open it with the files including the macros...

Thank you but I was thinking more about the solidworks document to see if the names of the sides corresponded with the program

the attached file 3217-1000_convoyeur_sortie_multivac2.xlsx I can't open it... Excel tells me that the file must be damaged???

The easiest way is to make a macro recording and modify the dimensions, in the code will be written the name of the dimensions to be modified

 

5 Likes

An Excel document with a macro should be saved in XLSM not in XLSX

5 Likes

My macro has changed slightly:

 

 

Sub Bouton1_Clic()

 

Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc

 

Part.Parameter("D4@Esquisse1@Longueur"). SystemValue = Range("D3"). Value / 1000
Part.ClearSelection
Part.ForceRebuild

 

Part.Parameter("D1@Extru.-Mince1@Largeur"). SystemValue = Range("D5"). Value / 1000
Part.ClearSelection
Part.ForceRebuild

 

End Sub

 And here is the Solidworks file, yes I know for the file, I can only save it in xlsx I don't know why...


3217-1000_convoyeur_sortie_multivac2.sldasm

I'm a pain but in the SW world you can't do anything without the components...  

The .SLDASM (assembly) file contains only the links to the parts .sldprt component files

 

Make a zip of the sldasm plus the .sldprt parts...

 

5 Likes

I'm sending you the .zip file in the early evening because I'm not going to be available before.

Sorry for the file format, thanks for your help earlier

 

Kind regards

1 Like

I'm not sure if this is what you wanted, I just turned my solidworks file into a .zip....


3217-1000_convoyeur_sortie_multivac2.zip

When you want to share an assembly, make a take-home composition (File/Take-Away Publication). You can save the whole thing directly in a zip file.

4 Likes

Hello

 

Whether you work with SolidEdge or SolidWorks, the principle is the same, the assemblies point to parts. So if you only send the assembly in the zip, we can't open it properly and therefore we can't help you.

So use the @Benoit.LF method, open your assembly and then use the take-away composition function in the  File menu. You can then make a zip containing all the necessary files.

 

On the other hand, I agree with those who don't see the point of making a macro for what you want to do.

A room family combined with a "configuration publisher" should do the trick.

 

@+

 

4 Likes

When you have your assembly in its right configuration (not in the SW sense, in the length sense, options...) what are you supposed to do with it? Extract (not in the EPDM sense...)  all the plan part files to rename them or add configurations to the existing files?

 

This is important for the direction you take in your design:

_ Room configurations> Solution @coyote, publisher

_ Rename all the pieces: rather make a basic model (TEMPLATE) that you re-register with a composition to take away.

 

 

1 Like

Hello, here is the file (sorry for my clumsiness)

Thank you Benoît for the approach


3217-1000_convoyeur_sortie_multivac2.zip
1 Like

Hi @ Alexis

in addition to all the previous info

 

I found you a link for the runtime error 91

http://www.developpez.net/forums/d1185252/logiciels/microsoft-office/excel/macros-vba-excel/erreur-d-execution-91-a/

 

(wishing I had helped you a little or knew nothing about macro)

 

@+ ;-)

 

Thanks gt22, but it doesn't work either..!