Hi All
I'm currently making modifications to a login script created by my senior IT colleagues and I've encountered an issue with the syntax that has stopped me in my tracks.
First and foremost I'm not exactly an expert when it comes to VBA, but I do know the basics.
First of all, I have created a simplified version of the ones I am having issues with, it is as follows:
FYI: the pathways/server names and files will be renamed for security reasons.
strPath = "\\VirtualServer1\Templates\Business Database"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFolder strPath, strUserDatabasePath
End If
This syntax works fine, all files are copied without issue.
However, when it comes to this lot of code:
strPath = "\\VirtualServer1\templates\Business Database\Graphics"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFolder strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Icons"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFolder strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database1.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database2.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database3.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database4.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database5.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
strPath = "\\VirtualServer1\templates\Business Database\Database6.accdb"
If IfFileExist(strPath) Then
strUserDatabasePath = "C:\ProgramData\Business Database"
objFSO.CopyFile strPath, strUserDatabasePath
End If
When I run this script, the Business Database folder is created, but the only contents within the folder are the files from the "Icons" and the "Graphics" folder.
I'm guessing there is any issue with the objFSO.CopyFile portion of the code? I thought this was valid syntax.
Any help would be greatly appreciated!