+ Reply to Thread
Results 1 to 5 of 5

Updating Current Workbook with New Version Via Code?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Updating Current Workbook with New Version Via Code?

    Hi there... I have a workbook that has various areas that are updated automatically via code but once in a while the entire workbook needs to be updated (code change or something else that can't be brought in to the old workbook). I am trying to find a way to do this via code... I find that users either don't update or don't get around to updating without a push. So I would like to do this automatically via code.

    I already have in place code that when the workbook is opened, it is moved to the proper folder and the original file location is removed. Now I am not sure if this is possible to do without the user having to do anything other than clicking the update button...

    What I would like to do is:
    • Download the new file from the network (already know how to do this).
    • Replace the current file while it is still open.
    • Open New file.
    • Delete old file.


    As I was typing this, I had an idea... would this work?
    Download the file from the network, save file to proper folder, changing its name temporarily. Open the new workbook, run code from the new workbook that closes the original workbook and deletes it, then renames the new workbook.

    Can something like this work? Any better ideas?

    Thanks
    Craig

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Updating Current Workbook with New Version Via Code?

    You can have a shared location have an excel file that is locked (so they cant update it) that houses ONE cell, the latest version of the workbook. Then if the latest version is greater than their version it forces them to either contact you for the update patch/macro or it can direct the user to the correct update in that same shared location.

    This assumes all users have access to that location.

    I had to implement something like this when I had 40 people on the team using different versions and complaining that things didn't work as they should. I just passed out an update macro to either replace their current workbook OR update the new workbook with data from the old workbook etc etc.


    It's a huge pain honestly, so I just had a quick check when the workbook opened to see if they had the latest version otherwise it would throw up a message box to contact me for the update. This let them know they were potentially at risk, and if they didnt need to do any work in the file, they could still use it to view data or something.



    Also, since I forced them to save their current versions on the shared drive, I used ADO to quickly rip the version number out of all the books so I could always tell if someone was on an old version.... really it takes multiple angles of attack as people will find a way to be lazy or stupid.
    Last edited by mikeTRON; 05-20-2016 at 02:26 PM.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Updating Current Workbook with New Version Via Code?

    The problem I face, is the users are all out in the field. They require use of the file when the are out and about. Now they can connect to our network if needed but it is not required for normal use. They do however need to connect to the network in order to update files.

    I need to work around this when they are connected to the network...

    Craig

  4. #4
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Updating Current Workbook with New Version Via Code?

    Yeah I had the EXACT same problem, so I had a version number on the title sheet. Whenever I emailed them all with an update macro, it would change to the newest version and that sheet was password protected so they were less likely to change it themselves. Then once you have multiple updates you have to add more logic in the code to validate that they are updating from the correct version (for example from 5.1 to 5.2 and not 5.0 to 5.2), or they can skip a few updates and not know it...

    I think I ended with that process, and the ADO check (which took literally seconds after it was created) monthly when they submitted their forecasts and such.

  5. #5
    Registered User
    Join Date
    10-18-2012
    Location
    Surrey, BC
    MS-Off Ver
    Excel 2016
    Posts
    84

    Re: Updating Current Workbook with New Version Via Code?

    So I did some testing and believe I came up with a solution for my needs.

    I downloaded and opened the updated workbook (Book2) from the original workbook(Book1).

    Set wb = Workbooks.Open(MyWBbook2)

    Added a few cell references to the updated workbook(Book2) from Original Workbook(Book1).

    wb.Sheets("MySheet").Range("A1").value = ActiveWorkBook.Name
    wb.Sheets("MySheet").Range("A2").value = ActiveWorkBook.Path & "\"
    I would add further information in Book2 for my real project to show the user the the update has been completed.
    Then close the original workbook(Book1) from original workbook(Book1).

    ThisWorkbook.Close SaveChanges:=False
    This leaves only Book2 open ans since the user must click a button to open the userforms we use, I can then get the code to check for the cell references I added, if found, the code would delete the original file, move the new updated file to the proper folder and give the user a completed update message when finished. The user won't even know the workbook has changed.

    I'm not sure if there is an easier way... but this seems to do the job!


    Craig

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Current version macro will work or not in future version
    By Sekars in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2016, 09:59 AM
  2. VBA code to copy data from current workbook to another workbook and send email
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-05-2015, 06:47 AM
  3. Get code that works on excel version 2007 to work on version 2010
    By Agent1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2014, 01:23 AM
  4. [SOLVED] How to restrict code to current workbook
    By troygeri in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-03-2014, 11:17 PM
  5. [SOLVED] Opening new workbook and pasting values into current workbook - code issues
    By Stew1234 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2014, 07:56 AM
  6. Use code to see if an online workbook is newer than local version
    By jcox1953 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2014, 10:13 PM
  7. [SOLVED] Place code from current workbook to new workbook
    By Qaspec in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-08-2005, 11:05 AM

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.6.0 RC 1