Share via


StencilPaths Property [Visio 2003 SDK Documentation]

Gets or sets the paths where Microsoft Office Visio looks for stencils.

strRet = object**.StencilPaths**

object**.StencilPaths** = pathsStr

strRet     String. A text string containing a list of folders.

object     Required. An expression that returns an Application object.

pathsStr     Required String. A text string containing a list of folders. Use semicolons to separate individual folders in the path string.

Version added

4.0

Remarks

The StencilPaths property is set to an empty string ("") by default.

The string passed to and received from the StencilPaths property is the same string shown in the File Paths dialog box. (On the Tools menu, click Options, click the Advanced tab, and then click File Paths.) This string is stored in the HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Visio\Application\StencilPath subkey.

When Visio looks for stencils, it looks in all paths named in the StencilPaths property and all the subfolders of those paths. If you pass the StencilPaths property to the EnumDirectories method, it returns a complete list of fully qualified paths in the folders passed in.

Setting the StencilPaths property replaces existing values for StencilPaths in the File Paths dialog box. To retain existing values, get the existing string and then append the new file path to that string, as shown in the following code:

Application.StencilPaths = Application.StencilPaths & ";" & "newpath".

Note  Modifying the registry in any manner, whether through the Registry Editor or programmatically, always carries some degree of risk. Incorrect modification can cause serious problems that may require you to reinstall your operating system. It is a good practice to always back up a computer's registry first before modifying it. If you are running Microsoft Windows NT or Microsoft Windows 2000, you should also update your Emergency Repair Disk (ERD).

Example

This Microsoft Visual Basic for Applications (VBA) macro shows how to us the StencilPaths property to add a path to the stencils.

Public Sub ShowStencilPaths_Example()
 
    Dim strMessage As String
    Dim strNewPath As String
    Dim strStencilPath As String
    Dim strTitle As String

    'Get the path we want to add. 
    strStencilPath = Application.StencilPaths 
    strTitle = "StencilPaths" 
    strMessage = "The current content of the Visio Stencils box is:" 
    strMessage = strMessage & vbCrLf & strStencilPath 
    MsgBox strMessage, vbInformation + vbOKOnly, strTitle 
    strMessage = "Type in an additional path for Visio to look for stencils. " 
    strNewPath = InputBox$(strMessage, strTitle) 

    'Make sure the folder exists and that it's not
    'already in the stencil paths. 
    strMessage = "" 
    If strNewPath = ""  Then
        strMessage = "You did not enter a path."
        ElseIf InStr(strStencilPath, strNewPath)  Then
            strMessage = "The path you specified is already in the stencil paths." 
        ElseIf Len(Dir$(strNewPath, vbDirectory)) = 0 And _ 
                Len(Dir$(Application.Path & strNewPath, _ 
                vbDirectory)) = 0 Then
            strMessage = "The folder you typed does not exist (or is blank)." 
        Else
            Application.StencilPaths = strStencilPath & ";" & strNewPath 
            strMessage = "We just added " & strNewPath & _ 
                " to the stencil paths." 
        End If
  
    If strMessage <> ""  Then
        MsgBox strMessage, vbExclamation + vbOKOnly, strTitle 
    End If
  
End Sub

Applies to | Application object | InvisibleApp object

See Also | AddonPaths property | DrawingPaths property | EnumDirectories method | HelpPaths property | Path property | StartupPaths property | TemplatePaths property