Map Citrix Network drive using UNC path VBA

ssingh75

Well-known Member
Joined
Jan 5, 2012
Messages
518
There is MS access database placed on Citrix environment and i'm trying to Map the network drive but getting error message.

Path = \\abcd365.sharepoint.com@SSL\DavWWWRoot\sites\CommunicationDev\test_tree\test\test1
I'm using the below code to map it....but getting error message.

Set objNet = CreateObject("WScript.Network")
If FolderExists(sharepointFileName) Then
objNet.RemoveNetworkDrive (strShareLetter)
Else
objNet.MapNetworkDrive strShareLetter, sharepointFileName, False, strUser, strPassword
End If
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Wondering about the special character(s) too. But if that's a literal post of the code line shouldn't it be enclosed in quotes? And where does the linking code make use of the Path variable?
 
Last edited:
Upvote 0
"but getting error message"

what's the error message ?

and is the @ sign really valid in a path ?


Error message is 'the operation being requested was not performed because the user has not been authenticated'

Yes @ is valid because the URL format is https...and is converted to UNC path...n m trying to map network drive on citrix enviorment.
 
Upvote 0
"the user has not been authenticated"

well that sounds like its expecting a password

There is nothing wrong with id and password...When i tried to map network drive manually using the id and password it worked well.
But i've received the error message as mentioned in the previous comment when tried using VBA.

Its citrix environment where i would like to map the network drive of sharepoint path in UNC format.
 
Upvote 0
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.
 
Last edited:
Upvote 0
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
 
Upvote 0
I would recommend you comment out the On Error GoTo ErrorHandler statement at the top. You do not want to hide errors when you are debugging a problem. This will allow the code to break on the lines that are having problems.

One thing that looks strange to me (two things) are that localPath isn't defined anywhere (could be a global variable?):
Code:
PstrFullfileName = localPath

Also this looks like it should be a string so it should be in quotes and I don't understand why it isn't in quotes:
Code:
sharepointFileName=\\abcd.sharepoint.com@SSL\DavWWWRoot\sites\CommunicationDev\test_tree\abd_UAT\Data

again, remove the error handling so you can get the actual lines where errors occur.
 
Upvote 0
I would recommend you comment out the On Error GoTo ErrorHandler statement at the top. You do not want to hide errors when you are debugging a problem. This will allow the code to break on the lines that are having problems.

One thing that looks strange to me (two things) are that localPath isn't defined anywhere (could be a global variable?):
Code:
PstrFullfileName = localPath

Also this looks like it should be a string so it should be in quotes and I don't understand why it isn't in quotes:
Code:
sharepointFileName=\\abcd.sharepoint.com@SSL\DavWWWRoot\sites\CommunicationDev\test_tree\abd_UAT\Data

again, remove the error handling so you can get the actual lines where errors occur.


Yes, I've updated the code accordingly but not luck yet. Could you please provide me the code for the same....

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top