Hide Table of Contents

Open And Save Document to 3DEXPERIENCE Example (VBA)

This example shows how to open and save a 3DEXPERIENCE document with SOLIDWORKS Connected.

'------------------------------------------------------------------
' Preconditions:
' 1. Open SOLIDWORKS Connected.
' 2. Open a new part.
' 3. Open the Immediate window.
' 4. Run the macro to the Stop.
' 5. Close the document in the user interface.
' 6. Press F5 to re-load the document from your collaborative space
'    in 3DEXPERIENCE.
'
' Postconditions:
' 1. NonActiveSave.sldprt is saved to a collaborative space
'    on the 3DEXPERIENCE platform and re-opened.
' 2. Use 3DEXPERIENCE 3DSearch to find NonActiveSave.sldprt
'    in your collaborative space.
'
' NOTE: Before running this example again, change strFileName to
'       a unique file name or delete NonActiveSave.sldprt.
'------------------------------------------------------------------
 
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModExt As SldWorks.ModelDocExtension
Dim swSaveTo3DExp As SldWorks.SaveTo3DExperienceOptions
Dim swPLMObjectSpecification As SldWorks.PLMObjectSpecification
Dim swDocSpecification As SldWorks.DocumentSpecification
Dim strPartTitle As String
Dim strPLMid As String
Dim strFileName, strComment As String
Dim bStat As Boolean
Dim lError As Long
Dim IWarning As Long
 
Sub main()
 
     Set swApp = Application.SldWorks
     Set swModel = swApp.ActiveDoc
     Set swModExt = swModel.Extension
    
     If swApp.ApplicationType = swApplicationType_3DEXPERIENCE Then
    
        Set swSaveTo3DExp = swApp.GetSaveTo3DExperienceOptions
 
        strFileName = "NonActiveSave.sldprt"
        strComment = "No comment"
        swSaveTo3DExp.FileName = strFileName
        bStat = swSaveTo3DExp.SetRevisionComments(strComment)
 
        bStat = swModExt.SaveTo3DExperience(swSaveTo3DExp, lError, IWarning)
 
        strPLMid = swModExt.GetPLMID
        Debug.Print swModel.GetPathName & " " & strPLMid
 
        Stop 'Close the document in the user interface
 
        'Re-open the document from 3DEXPERIENCE
        Set swDocSpecification = swApp.GetOpenDocSpec("")
        Set swPLMObjectSpecification = swDocSpecification.PLMObjectSpecification
        swPLMObjectSpecification.PLMID = strPLMid
 
        Set swModel = swApp.OpenDoc7(swDocSpecification)
         
     End If
 
End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Open And Save Document to 3DEXPERIENCE Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2020 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.