Hide Table of Contents
GetOpenedFileInfo Method (ISldWorks)

Gets the name of the last model successfully opened by SOLIDWORKS and the options that were in effect when it opened.

.NET Syntax

Visual Basic (Declaration) 
Sub GetOpenedFileInfo( _
   ByRef FileName As System.String, _
   ByRef Options As System.Integer _
Visual Basic (Usage) 
Dim instance As ISldWorks
Dim FileName As System.String
Dim Options As System.Integer
instance.GetOpenedFileInfo(FileName, Options)
void GetOpenedFileInfo( 
   out System.string FileName,
   out System.int Options
void GetOpenedFileInfo( 
&   [Out] System.String^ FileName,
&   [Out] System.int Options


Full path and filename of the last model successfully opened by SOLIDWORKS
Options in effect when FileName opened as defined in swOpenDocOptions_e


Dim swApp As SldWorks.SldWorks
Dim path As String
Dim docspec As SldWorks.DocumentSpecification
Dim opened As String
Dim Options As Long
Dim Part As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Option Explicit
Sub main()
    Set swApp = Application.SldWorks
swApp.CloseAllDocuments True
path = "C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\tutorial\api\bagel.sldprt"
Set docspec = swApp.GetOpenDocSpec(path)
Set Part = swApp.OpenDoc7(docspec)
Set Part = swApp.OpenDoc6("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\tutorial\api\coffeecup.sldprt", 1, 0, "", longstatus, longwarnings)
Set Part = swApp.OpenDoc6("C:\Users\Public\Documents\SOLIDWORKS\SOLIDWORKS 2018\tutorial\api\toaster.sldprt", 1, 0, "", longstatus, longwarnings)

' None of the above documents successfully opened through the API get returned by GetOpenedFileInfo
swApp.GetOpenedFileInfo opened, Options
Debug.Print "Last successfully opened file: " & opened
Debug.Print "Options as defined in swOpenDocOptions_e: " & Options

End Sub


This method considers only models opened through the SOLIDWORKS user interface. This method does not consider models successfully opened through the API, unless the API opens an assembly. In that case, each assembly component is opened by SOLIDWORKS, and this method determines which of those assembly's components was successfully opened last.

See Also


SOLIDWORKS 2005 FCS, Revision Number 13.0

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

Subject:   Feedback on Help Topics
Page:   GetOpenedFileInfo Method (ISldWorks)
*   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:


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

Web Help Content Version: API Help (English only) 2019 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.