Lea, proba el siguiente codigo que arme:
'---------------------------------------------------------------------------------------
' Module : mdlSharedMagic
' Author : Cocus (santiagohssl@gmail.com)
' DateTime : 11/05/2014
' Legal : Free to use and distribute. You may not reproduce or publish this
' code on any website, online service, or distribute as source on
' any media without express permission from author.
' References :
' Thanks To :
' Purpose : Logon to remote sharing servers (SMB).
' Revisions : #0 11/05/2014 - Cocus: First cut
'---------------------------------------------------------------------------------------
Option Explicit
Private Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
Private Const RESOURCETYPE_ANY As Long = &H0
Private Const CONNECT_UPDATE_PROFILE As Long = &H1
Private Declare Function WNetAddConnection2A Lib "mpr.dll" (ByRef lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
Public Function AddConnection(ByVal sServer As String, _
ByVal sUserName As String, _
Optional ByVal sPassword As String, _
Optional ByVal sLocalShare As String = vbNullString) As Boolean
Dim tResource As NETRESOURCE
With tResource
.dwType = RESOURCETYPE_ANY
.lpRemoteName = sServer
.lpProvider = vbNullString
.lpLocalName = sLocalShare
End With
If WNetAddConnection2A(tResource, sPassword, sUserName, CONNECT_UPDATE_PROFILE) Then
Err.Raise Err.LastDllError, "WNetAddConnection2A", "Error connecting to server. GetLastErrror() = " & Err.LastDllError
Else
AddConnection = True
End If
End Function
Llamalo asi:
Call AddConnection("\\192.168.0.2\shared", "usuario", "contraseña")
Debug.Print Dir("\\192.168.0.2\shared\")
Yo probe con una pc con XP y funciona perfecto.
Un saludo