+ Reply to Thread
Results 1 to 6 of 6

Thread: Linking Workbooks?

  1. #1
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    85

    Linking Workbooks?

    Hey all!
    I want to first say THANK YOU for all of the help over the past 2 years. I believe that my big project is finally done (for now!) However I do have one thing on my mind and troubing me.

    Every time I have an update for my end users (a new userform or a change to one, or a new sheet), I have to put it on a flash drive, and load it onto every computer (or email it to them)

    Is there a way where I can have Excel or maybe a small .net program check for a new version that I have uploaded onto a server, and download the new version?

    Thanks in advance!

  2. #2
    Valued Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: Linking Workbooks?

    Can you not put your file onto a shared drive and have your users access that instead of having many different versionsn on the client computers?

  3. #3
    Registered User
    Join Date
    04-04-2009
    Location
    Nashville, TN,USA
    MS-Off Ver
    Excel 2007
    Posts
    85

    Re: Linking Workbooks?

    All of the end users are on laptops in the field. When they come back to the office for whatever reason is when there computers will update.

  4. #4
    Valued Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: Linking Workbooks?

    Hi

    You'd need to make a record of when the client file was first downloaded. Then compare that date to the modified date of the master file when the user has access to the network drive.

    The following code does the following when the file is opened:

    1) If Thisworkbook is not the master file (in this case the master file is "E:\Excel VBA\Project File.xlsm") then it records the date and time in Cell A1 on Sheet1 if that cell is empty. This date becomes the date that the client file was first downloaded from the network.

    2) If the user has access to the E drive then it will check if the master file is newer than the date in cell A1. If it is, the user will be shown a msgbox asking them to download the newer master file.

    Automatically downloading the new file for the user will be difficult because (I'm assuming) the file names of the client and master files will be the same.....

    You'll need to customise these two variables to suit your needs:

    Set varDLdate = Sheets("Sheet1").Range("A1")
    varWBmasterStr = "E:\Excel VBA\Project File.xlsm"

    Sub Auto_Open()
    
    On Error Resume Next
    
    Dim varDLdate As Range
    Dim varWBmasterStr As String
    Dim varWBclientStr As String
    Dim varWBmasterModDate As Date
    Dim varWBclientModDate As Date
    Dim varWBclientDLDate As Date
    
    Set varDLdate = Sheets("Sheet1").Range("A1")
    varWBmasterStr = "E:\Excel VBA\Project File.xlsm"
    varWBclientStr = ThisWorkbook.FullName
    
    'Exit if the current workbook is the master file
    If Left$(varWBclientStr, 1) = Left$(varWBmasterStr, 1) Then
        varDLdate.Value = ""
        Exit Sub
    End If
    
    'Record the date if the download date cell is empty
    If varDLdate.Value = "" Then
        varDLdate.Value = Now
    End If
    
    'Check if master file exists and get modified dates
    If Dir(varWBmasterStr) = "" Then
        'Do nothing (the master file does not exist or the user isn't on the network)
    Else
        'Get the modified date (for master file) and download date (for client file)
        varWBmasterModDate = FileLastModified(varWBmasterStr)
        varWBclientModDate = FileLastModified(varWBclientStr)
        varWBclientDLDate = varDLdate.Value
        
        If varWBmasterModDate > varWBclientDLDate Or varWBmasterModDate > varWBclientModDate Then
            MsgBox "An updated version of the file exists." & _
            vbNewLine & vbNewLine & "Please download the latest version from:" & _
            vbNewLine & vbNewLine & varWBmasterStr
        End If
    End If
    
    End Sub
    
    Function FileLastModified(strFullFileName As String)
    Dim fs As Object, f As Object, s As String
    
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(strFullFileName)
    
    s = f.DateLastModified
    FileLastModified = s
    
    Set fs = Nothing: Set f = Nothing
    
    End Function
    Last edited by mojo249; 12-05-2010 at 09:46 AM. Reason: Amended to allow for scenario where user downloads master file but doesn't use it.

  5. #5
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: Linking Workbooks?

    Did you know ?

    c01=FileDatetime("E:\Of\simple.xls")

    it does exactly the same thing as
    Function FileLastModified(strFullFileName As String)
    Dim fs As Object, f As Object, s As String

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(strFullFileName)

    s = f.DateLastModified
    FileLastModified = s

    Set fs = Nothing: Set f = Nothing

    End Function
    It's worth while to press on F2 in the VBEditor to study all the methods in the VBA-library. Do not invent what has been built-in.



  6. #6
    Valued Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    290

    Re: Linking Workbooks?

    Did you know ?

    No, obviously I didn't. But it's useful to know so thanks for pointing it out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0