Code:
Set objNet = CreateObject("WScript.Network")
If FolderExists(sharepointFileName) Then
objNet.RemoveNetworkDrive (strShareLetter)
Else
objNet.MapNetworkDrive strShareLetter, sharepointFileName, False, strUser, strPassword
End If
This code fragment is incomplete - non of the variables are defined or given values. I think you might need to provide more details and describe how you are using the code.
Note that generally I've found citrix questions to be difficult to answer - most people don't have a citrix environment to test in and it appears that it can be quite different where VBA is involved.
Below is the entire code...
On Error GoTo ErrorHandler
Dim Path As String
Dim pw As String
Dim Username As String
Dim docName As String
Dim docX As Variant
Dim Lvarbin() As Byte
Dim LobjXML As Object
Dim LstrFileName As String
Dim LvarBinData As Variant
Dim rtn As Boolean
'//Added by Susheel
Dim objNet As Object
Dim FS As Object
Dim objFolder As Object
Dim strShareLetter As String
Dim strURL As String, strUser As String, strPassword As String
strShareLetter = "S:"
strUser = "Singh.Susheelkumar@abc.com"
'' strUser = "abc\a12345"
strPassword = "Ad@ef1987"
PstrFullfileName = localPath
sharepointFileName=\\abcd.sharepoint.com@SSL\DavWWWRoot\sites\CommunicationDev\test_tree\abd_UAT\Data
''''''' Map_Drive strShareLetter, sharepointFileName
Set objNet = CreateObject("WScript.Network")
If FolderExists(sharepointFileName) Then
objNet.RemoveNetworkDrive (strShareLetter)
Else
objNet.MapNetworkDrive strShareLetter, sharepointFileName, False, strUser, strPassword
End If
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(PstrFullfileName) Then
'' If FS.FileExists(PstrTargetURL) Then
FS.CopyFile PstrFullfileName, PstrTargetURL
'' End If
End If
'//Code to remove the network drive
objNet.RemoveNetworkDrive (strShareLetter)
Set objNet = Nothing
Set FS = Nothing
ErrorHandler:
'' Debug.Print Err.Number & vbCrLf & Err.Description
MsgBox Err.Number & vbCrLf & Err.Description
'' GoTo ExitHandler
'' Resume