OVH Cloud OVH Cloud

Lecteur réseaux

3 réponses
Avatar
Tony
Bonjour,

Est-il possible de monter un lecteur réseaux à partir d'Excel ?

Merci par avance.

Cordialement.

3 réponses

Avatar
Alain CROS
Bonjour

Je n'ai pas de réseau sous la main mais essaye comme ça.

Sub LienReseau()
Dim WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "G:", "OrdiPartage", , , "LeMotDePasse"
Set WshNetwork = Nothing
End Sub

Voici la doc.

MapNetworkDrive Method

Adds a shared network drive to your computer system.

object.MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
Arguments
object
WshNetwork object.
strLocalName
String value indicating the name by which the mapped drive will be known locally.
strRemoteName
String value indicating the share's UNC name (xxxyyy).
bUpdateProfile
Optional. Boolean value indicating whether the mapping information is stored in the current user's profile. If bUpdateProfile is
supplied and has a value of true, the mapping is stored in the user profile (the default is false).
strUser
Optional. String value indicating the user name. You must supply this argument if you are mapping a network drive using the
credentials of someone other than the current user.
strPassword
Optional. String value indicating the user password. You must supply this argument if you are mapping a network drive using the
credentials of someone other than the current user.

Alain CROS

"Tony" a écrit dans le message de news:
| Bonjour,
|
| Est-il possible de monter un lecteur réseaux à partir d'Excel ?
|
| Merci par avance.
|
| Cordialement.
|
Avatar
Tony
Bonjour Alain,

Merci beaucoup pour votre aide.
Cela marche parfaitement.

Si je peux encore abuser, sauriez-vous comment on déconnecte un lecteur
réseaux ?

Cordialement.



Bonjour

Je n'ai pas de réseau sous la main mais essaye comme ça.

Sub LienReseau()
Dim WshNetwork
Set WshNetwork = CreateObject("WScript.Network")
WshNetwork.MapNetworkDrive "G:", "OrdiPartage", , , "LeMotDePasse"
Set WshNetwork = Nothing
End Sub

Voici la doc.

MapNetworkDrive Method

Adds a shared network drive to your computer system.

object.MapNetworkDrive(strLocalName, strRemoteName, [bUpdateProfile], [strUser], [strPassword])
Arguments
object
WshNetwork object.
strLocalName
String value indicating the name by which the mapped drive will be known locally.
strRemoteName
String value indicating the share's UNC name (xxxyyy).
bUpdateProfile
Optional. Boolean value indicating whether the mapping information is stored in the current user's profile. If bUpdateProfile is
supplied and has a value of true, the mapping is stored in the user profile (the default is false).
strUser
Optional. String value indicating the user name. You must supply this argument if you are mapping a network drive using the
credentials of someone other than the current user.
strPassword
Optional. String value indicating the user password. You must supply this argument if you are mapping a network drive using the
credentials of someone other than the current user.

Alain CROS

"Tony" a écrit dans le message de news:
| Bonjour,
|
| Est-il possible de monter un lecteur réseaux à partir d'Excel ?
|
| Merci par avance.
|
| Cordialement.
|





Avatar
Alain CROS
Bonjour.

Copie de la doc :

RemoveNetworkDrive Method

Removes a shared network drive from your computer system.

object.RemoveNetworkDrive(strName, [bForce], [bUpdateProfile])
Arguments
object
WshNetwork object.
strName
String value indicating the name of the mapped drive you want to remove. The strName parameter can be either a local name or a
remote name depending on how the drive is mapped.
bForce
Optional. Boolean value indicating whether to force the removal of the mapped drive. If bForce is supplied and its value is true,
this method removes the connections whether the resource is used or not.
bUpdateProfile
Optional. String value indicating whether to remove the mapping from the user's profile. If bUpdateProfile is supplied and its value
is true, this mapping is removed from the user profile. bUpdateProfile is false by default.
Remarks
If the drive has a mapping between a local name (drive letter) and a remote name (UNC name), then strName must be set to the local
name. If the network path does not have a local name (drive letter) mapping, then strName must be set to the remote name.

Example
The following code removes the logical drive "E."

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")
WshNetwork.RemoveNetworkDrive "E:"

Alain CROS

"Tony" a écrit dans le message de news:
| Bonjour Alain,
|
| Merci beaucoup pour votre aide.
| Cela marche parfaitement.
|
| Si je peux encore abuser, sauriez-vous comment on déconnecte un lecteur
| réseaux ?
|
| Cordialement.
|