Consulting

Results 1 to 4 of 4

Thread: VBA login script help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Mar 2015
    Posts
    3
    Location

    VBA login script help

    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!
    Last edited by Bob Phillips; 03-06-2015 at 01:59 AM. Reason: Added code tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •