Q Control

Hello

When I close the Excel file of my family of parts, I would like there to be an automatic Q control. Is  it possible. Thank you in advance

Hello

Here is a VBA code that I found on the net that validates the configurations in Solidworks, see if you can adapt it to Excel. 

Sub main()

    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim swConfigMgr                 As SldWorks.ConfigurationManager
    Dim swConfig                    As SldWorks.Configuration
    Dim vConfigName                 As Variant
    Dim sSpecConfigNameArr(0)       As String
    Dim vSpecConfigNameArr          As Variant
    Dim dimValue                    As Variant
    Dim stnameConfig As String
   
    Set swApp = Application.SldWorks
    'on récupére le document actif
    Set swModel = swApp.ActiveDoc
    
    Set swConfigMgr = swModel.ConfigurationManager
    'on récupére la configuration active
    Set swConfig = swConfigMgr.ActiveConfiguration
    'on récupére de nom de la configation active
    stnameConfig = swConfig.Name
    'on récupére le nom de toutes les configurations
    vConfigNameArr = swModel.GetConfigurationNames
    'on boucle
    For Each vConfigName In vConfigNameArr
        'on affiche la configuration
        swModel.ShowConfiguration2 vConfigName
         'on force la reconstruction
        swModel.ForceRebuild3 False
       
    Next vConfigName
        
    'on affiche la configuration active avant le traitement
    swModel.ShowConfiguration2 stnameConfig
    'on force la reconstruction
    swModel.ForceRebuild3 False
    'on sauvegarde le document
    swModel.Save3 swSaveAsOptions_e.swSaveAsOptions_Silent, 0, 0
    
End Sub

 

2 Likes

Hello

The code given by our friend ac cobra 427 seems to me to be a very good example to adapt in an Excel macro, this one is to be transformed into a function that will have to be called before the end of Excel, for this see https://forum.excel-pratique.com/excel/executer-une-macro-a-la-fermeture-de-mon-classeur-t31649.html.

Kind regards

1 Like