Change PhotoWorks Search Paths Example (VBA)
This example shows how to change the paths that PhotoWorks searches
for missing files.
'------------------------------------------
'
' Preconditions: The PhotoWorks add-in is loaded.
'
' Postconditions: The list of paths that PhotoWorks searches
for
' missing
files is changed.
'
'---------------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Sub main()
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
PrintFolders
pwopt
'
'
Change search paths
'
'
Clear the list of search paths
bRetVal
= pwopt.ClearSearchPathList
'
Add new search paths
'
Existing folder
bRetVal
= pwopt.AddSearchPath("C:\")
'
Non-existing folder
bRetVal
= pwopt.AddSearchPath("C:\Nonexisting
folder")
'
Folder that may or may not exist
bRetVal
= pwopt.AddSearchPath("C:\temp")
'
Folder that may or may not exist
bRetVal
= pwopt.AddSearchPath("C:\tmp")
'
Existing folder
bRetVal
= pwopt.AddSearchPath("C:\windows")
'
Print current settings to Visual Basic Immediate window
PrintFolders
pwopt
End Sub
Sub PrintFolders(ByRef pwopt As PhotoWorks.PwOptions)
Dim
vSearchFileList As
Variant
Dim
lPathItr As
Long
Debug.Print
"File Locations:"
Debug.Print
" Search
paths:"
Debug.Print
" Number
of serach paths = " & CStr(pwopt.GetSearchPathListCount)
If
pwopt.GetSearchPathListCount >
0 Then
vSearchFileList
= pwopt.GetSearchPathList()
For
lPathItr = LBound(vSearchFileList) To UBound(vSearchFileList)
Debug.Print
" "
& vSearchFileList(lPathItr)
Next
lPathItr
End
If
Debug.Print
" Search
sub-folders = " & CStr(pwopt.SearchSubFolders)
End Sub