Hi Everyone,
The VBA code works with the files stored on shared drive. The path to the folders and files is defined in the VBA code as " \\server\path\folder with data\". (See extract of code below).
I have not had any issues with running VBA scripts by referencing this path before. However, today, when running a VBA script, I get a "run time error 52 bad file name or number" whenever the VBA code line contains reference to files or folders on the shared drive. The issue is solved if instead of "\\server\sharename\folder with data\" I write "Y:\path\folder with data\", where "Y" is the local machine drive name of this shared drive.
The VBA needs to be used on different machines where the local name of the shared drive may be different . So replacing the path with "Y:\path\folder with data\" does not seem like a workable solution. Is there any other ways to solve the issue?
Extract of VBA for reference (lines of code where error is thrown out are marked in bold).
The VBA code works with the files stored on shared drive. The path to the folders and files is defined in the VBA code as " \\server\path\folder with data\". (See extract of code below).
I have not had any issues with running VBA scripts by referencing this path before. However, today, when running a VBA script, I get a "run time error 52 bad file name or number" whenever the VBA code line contains reference to files or folders on the shared drive. The issue is solved if instead of "\\server\sharename\folder with data\" I write "Y:\path\folder with data\", where "Y" is the local machine drive name of this shared drive.
The VBA needs to be used on different machines where the local name of the shared drive may be different . So replacing the path with "Y:\path\folder with data\" does not seem like a workable solution. Is there any other ways to solve the issue?
Extract of VBA for reference (lines of code where error is thrown out are marked in bold).
VBA Code:
Dim strFileName As String
Dim strFileExists As String
'Check the file name ending
strFileName = "\\server\path\folder with data\DataFile_" & dYes & "_" & dTod & "_000501UTC.zip"
[B]strFileExists = Dir(strFileName)[/B]
If strFileExists = "" Then '.zip file to be unzipped
localZipFile = ""\\server\path\folder with data\DataFile_" & dYes & "_" & dTod & "_000502UTC.zip"
Else
localZipFile = ""\\server\path\folder with data\DataFile_" & dYes & "_" & dTod & "_000501UTC.zip"
End If
destFolder = ""\\server\path\second folder with data\" 'destination folder of .zip file's unzipped contents
'Unzip all files in the .zip file
Set Sh = CreateObject("Shell.Application")
With Sh
[B].Namespace(destFolder).CopyHere .Namespace(localZipFile).Items[/B]
End With