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