MapNetworkDrive Not working in Win 7 - Error 75 for bad Path file Name

pmrsed

New Member
Joined
Jan 26, 2019
Messages
7
Hi!

This code works beautifully at work on Win 10 but not so much for Win 7 machines. They die on the MapNetworkDrive statement below. Is it due to Windows Credentials not being available?

MapNetworkDrive 'Map SharePoint Online ATHLETICS Approved Documents as Network drive P:


Here is an excerpt:
--------------------------------------------
Option Explicit

Public objFS As Object
Public objNet As Object
Public objFile As Object
Public objFolder As Object

Public WSD As Worksheet

Public strToFolder As String
Public strDirectory As String
Public strToFileName As String
Public strArtifactName As String
Public strFromFileName As String
Public strNTSUFolder As String
Public strSPOLnetworkDrive As String
Public strSharepointAddress As String
Public strSharepointPath As String

Public intI As Integer
Public intFinalRow As Integer

Public strUser$, strPassword$, strNetworkDrive$


-----------------------------------------------------------------------------
Sub CopyFilesTo1stFolder()

strSharepointPath = "xxxxxxxxxxxxxxxxxxxxxxxx"
strNTSUFolder = Application.InputBox("Enter ATHL NTSU ID to build the folder")

If strNTSUFolder = "False" Then 'Get the starting folder
MsgBox "Nothing entered.....Good bye"
Exit Sub
End If

strNTSUFolder = Trim(strNTSUFolder) 'Remove trailing spaces'
strToFolder = "M:\NTSU Systems\ NTSU Folders\ATHL NTSU" & strNTSUFolder

strNetworkDrive = "P:"
MapNetworkDrive 'Map SharePoint Online ATHLETICS Approved Documents as Network drive P:

If Len(Dir("" & strToFolder & "", vbDirectory)) = 0 Then
MkDir strToFolder
Else
MsgBox "This folder already exists " & strToFolder
Exit Sub
End If

Set WSD = ThisWorkbook.Worksheets("Listing")
intFinalRow = WSD.Cells(Rows.Count, 1).End(xlUp).Row

MsgBox "COMPLETE - Folder " & strNTSUFolder & " created in M:\NTSU Systems\ NTSU Folders\ATHL NTSU"

End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I left out the main Sub!

Hi!

This code works beautifully at work on Win 10 but not so much for Win 7 machines. They die on the MapNetworkDrive statement below. Is it due to Windows Credentials not being available?

[MapNetworkDrive] 'Map SharePoint Online ATHLETICS Approved Documents as Network drive P:


Here is an excerpt:
--------------------------------------------
Code:
   Option Explicit

 Public objFS                      As Object
 Public objNet                     As Object
 Public objFile                    As Object
 Public objFolder                  As Object

 Public WSD                        As Worksheet

 Public strToFolder                As String
 Public strDirectory               As String
 Public strToFileName              As String
 Public strArtifactName            As String
 Public strFromFileName            As String
 Public strNTSUFolder           As String
 Public strSPOLnetworkDrive        As String
 Public strSharepointAddress       As String
 Public strSharepointPath          As String

 Public intI                       As Integer
 Public intFinalRow                As Integer

 Public strUser$, strPassword$, strNetworkDrive$


 -----------------------------------------------------------------------------
 Sub CopyFilesTo1stFolder()

strNTSUFolder = Application.InputBox("Enter ATHL NTSU ID to build the folder")

   If strNTSUFolder = "False" Then   'Get the starting folder
      MsgBox "Nothing entered.....Good bye"
      Exit Sub
   End If

   strNTSUFolder = Trim(strNTSUFolder) 'Remove trailing spaces'
   strToFolder = "M:\NTSU Systems\ NTSU Folders\ATHL NTSU\" & strNTSUFolder

   strNetworkDrive = "P:"
   MapNetworkDrive            'Map SharePoint Online ATHLETICS Approved Documents as Network drive P:

   If Len(Dir("" & strToFolder & "", vbDirectory)) = 0 Then
      MkDir strToFolder
   Else
      MsgBox "This folder already exists " & strToFolder
      Exit Sub
   End If

   MsgBox "COMPLETE - Folder  " & strNTSUFolder & " created in M:\NTSU Systems\ NTSU Folders\ATHL NTSU"

 End Sub

 -------------------------------
 Sub MapNetworkDrive()

   strSharepointAddress = "xxxxxxxxxxxxxxxxxxxxxxx

   If Dir(strNetworkDrive & "\", vbDirectory) = "" Then
   'There is NO mapped network P: drive
   Else
      strSPOLnetworkDrive = strNetworkDrive   'Network drive P: is already mapped
      Exit Sub
   End If

   Set objNet = CreateObject("WScript.Network")
   Set objFS = CreateObject("Scripting.FileSystemObject")

   objNet.MapNetworkDrive strNetworkDrive, strSharepointAddress

   Set objFolder = objFS.getfolder(strNetworkDrive)
   strSPOLnetworkDrive = strNetworkDrive

 End Sub   [Code]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,676
Messages
6,126,165
Members
449,295
Latest member
DSBerry

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