Hide Table of Contents

Change PhotoWorks Custom Folders Example (VBA)

This example shows how to get the names of the active custom folders and how to change the active custom folders.

 

'------------------------------------------

'

' Preconditions: The PhotoWorks add-in is loaded.

'

' Postconditions:

'   (1) The list of custom folders is changed.

'   (2) A new active custom folder is set.

'

'---------------------------------------------

Option Explicit

 

Sub main()

 

    Dim swApp                   As SldWorks.SldWorks

    Dim pwAddIn                 As PhotoWorks.PhotoWorks

    Dim pwopt                   As PhotoWorks.PwOptions

    Dim bRetVal                 As Boolean

    

    

    

    ' Get the SolidWorks application

    Set swApp = Application.SldWorks

    

    ' Get the PhotoWorks add-in

    Set pwAddIn = swApp.GetAddInObject("PhotoWorks.PhotoWorks")

    

    ' Get the PhotoWorks options

    Set pwopt = pwAddIn.PwOptions()

    

    ' Print current settings to the Visual Basic Immediate window

    PrintCustomFolders pwopt

    

    '

    ' Change the custom folders

    '

    

    ' Clear list of custom folders

    bRetVal = pwopt.ClearCustomFolderList

    

    ' Add new folders

    

    ' Existing folder

    bRetVal = pwopt.AddCustomFolder("C:\")

    

    ' Non-existing folder

    bRetVal = pwopt.AddCustomFolder("C:\Nonexisting folder")

    

    ' Folder that may or may not exist

    bRetVal = pwopt.AddCustomFolder("C:\temp")

    

    ' Folder that may or may not exist

    bRetVal = pwopt.AddCustomFolder("C:\tmp")

    

    ' Set active folder; also adds it to list of custom folders

    ' Folder that may or may not exist

    bRetVal = pwopt.AddCustomFolder("C:\windows")

    

    ' Print current settings to Visual Basic Immediate window

    PrintCustomFolders pwopt

    

End Sub

 

Sub PrintCustomFolders(ByRef pwopt As PhotoWorks.PwOptions)

    Dim vCustomFolders          As Variant

    Dim lPathItr                As Long

    Dim strActiveCustomFolder   As String

    Dim strCustomFolder         As String    

    

    Debug.Print "File Locations:"

    Debug.Print "  Custom folders:"

    Debug.Print "    Number of active custom folders = " & CStr(pwopt.GetCustomFolderListCount)

    If pwopt.GetCustomFolderListCount > 0 Then

        

        strActiveCustomFolder = pwopt.GetActiveCustomFolder

        

        vCustomFolders = pwopt.GetCustomFolderList()

        

        For lPathItr = LBound(vCustomFolders) To UBound(vCustomFolders)

        

            strCustomFolder = vCustomFolders(lPathItr)

            

            If strCustomFolder = strActiveCustomFolder Then

                Debug.Print "      " & strCustomFolder & " <active>"

            Else

                Debug.Print "      " & strCustomFolder

            End If

                

        Next lPathItr

        

    End If

    

    Debug.Print "    Autoload selected folders = " & CStr(pwopt.AutoLoadSelectedFolder)

    Debug.Print "    Suppress standard materials = " & CStr(pwopt.SuppressStandardMaterials)

    

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:   Change PhotoWorks Custom Folders 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) 2010 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.