Connect Method

Microsoft Word Visual Basic

Establishes a connection to a network drive.

Security   Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code. For recommended best practices on how to do this, see Security Notes for Microsoft Office Solution Developers.

expression.Connect(Path, Drive, Password)

expression    Required. An expression that returns a System object.

Path    Required String. The path for the network drive (for example, "\\Project\Info").

Drive    Optional Variant. A number corresponding to the letter you want to assign to the network drive, where 0 (zero) corresponds to the first available drive letter, 1 corresponds to the second available drive letter, and so on. If this argument is omitted, the next available letter is used.

Password    Optional Variant. The password, if the network drive is protected with a password.

Remarks

Use the Dialogs property with the wdDialogConnect constant to display the Connect To Network Drive dialog box. The following example displays the Connect To Network Drive dialog box, with a preset path shown.

With Dialogs(wdDialogConnect)
    .Path = "\\Marketing\Public"
    .Show
End With
		

Example

This example establishes a connection to a network drive (\\Project\Info) protected with the password contained in the String variable, and then assigns the network drive to the next available drive letter.

System.Connect Path:="\\Project\Info", Password:=strPassword
		

This example establishes a connection to a network drive (\\Team1\Public) and assigns the network drive to the third available drive letter.

System.Connect Path:="\\Team1\Public", Drive:=2