+ Reply to Thread
Results 1 to 10 of 10

Multi-user access to a VBA-application

Hybrid View

  1. #1
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Multi-user access to a VBA-application

    The short story: What I have is VBA-application, imbedded in an otherwise empty MS Excel (2007) file . What I want is for multiple users to be able to open and use this VBA-application simultaneously from a shared network location.

    The longer story: The application is used for financial simulations. Basically, the user selects a whole string of settings and parameters on a input form, the application does some calculations, and then it returns the corresponding financial data on a second user form. It’s made my work quite a bit easier in the past. So much so, in fact, that we’ve decided to make it available to all our employees. But as it turns out, transforming what was originally intended as a simple tool for personal use into a full-fledged, multi-user application, isn’t that simple after all.

    Some background information: The project started out as a spreadsheet with some built-in automation through VBA-code. As I continued to expand on the latter, the former became largely irrelevant, until I ended up with a virtually independent VBA-application, which happens to be stuck in an otherwise empty Excel-file.

    If I would have the time, I would of course start over, and recreate the tool as a stand-alone executable in VB or Java. But rewriting several thousand lines of source code is simple not an option at this time. (Note that this exorbitant length is mostly due to my lack of programming skill. It could easily be reduced in size by at least 80% by extracting the financial parameters – which are currently hard-coded – and retrieving this information as needed from a separate database or ini-file. I intend to do this, as soon as I figure out how.)

    The fact that I’m stuck with MS Excel poses quite a few problems, but the main issue is that Excel files are unsuited for simultaneous access by multiple users, or so I've been told. The simple solution would of course be to send everyone a copy of the file. This is not an option, however, because the tool requires frequent updates in order to ensure the continued accuracy of the calculations, and we can’t afford the risk of people accidently using an outdated version, As such, airtight and fool-proof versioning is absolutely essential.

    The current solution We're thinking about creating a script or batch file which would copy the most recent version (and, optionally, the supporting database or ini-file) from the server to the user’s temporary folder, overwriting any previous versions, and then open that copy. A link to this script would be placed in the software section of our intranet. I would work, I guess, but it’s far from elegant, and doesn’t completely eliminate the risk of people using the wrong version (e.g. by accessing an outdated copy though “recently used documents”).

    The question: Should any of you have a better idea on how to achieve this, please feel free to enlighten me!
    Last edited by nymm; 05-03-2011 at 08:01 AM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Multi-user access to a VBA-application

    It may be possible to open the Excel file directly on the web page without users downloading and viewing in Excel natively...
    If your question has been satisfactorily addressed, please consider marking it solved. Click the Thread Tools dropdown and select Mark thread as solved.
    Also, you might want to add to the user's reputation by clicking the star icon in the lower left corner of the post with the answer- it's why we do what we do...

    Thomas Lafferty
    Analyst/Programmer

  3. #3
    Registered User
    Join Date
    10-22-2007
    Location
    Mumbai, India
    MS-Off Ver
    MS Excel 2007
    Posts
    59

    Re: Multi-user access to a VBA-application

    Hi,

    Multiple users can simultaneously use the same file and will not face any issue untill and unless you are saving any information in the file. You can protect the file and allow everyone to open it in a read only mode. Ensure that the file is not in a shared mode. Hope this helps.

    Regards
    Roshan
    Last edited by Roshan10043; 04-29-2011 at 12:13 PM.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Multi-user access to a VBA-application

    What you need is to save the existing workbook as an addin, this can then be deployed on the server and each user could install & use the addin. You would need to either have a customised ribbon tab or a menu for access to the tools
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Multi-user access to a VBA-application

    First off, thank you all for the input!

    It may be possible to open the Excel file directly on the web page without users downloading and viewing in Excel natively...
    That sounds really interesting, but I have absolutely no idea how that could be achieved. Could you please elaborate?

    Multiple users can simultaneously use the same file and will not face any issue untill and unless you are saving any information in the file.
    I've already included some code to intercept and discard any attempt to save the file, and to prevent the "Save changes?" dialog on closing the file. Unfortunately, this doesn't prevent Excel from prompting the user to "Save As" when the file is opened as read only, or when it is accessed from a server location where the user has read only rights (as is my intention).

    What you need is to save the existing workbook as an addin, this can then be deployed on the server and each user could install & use the addin.
    I'd first have to learn how to create a tab or menu, and rework the interface a bit, but that sounds promising too. I'm just wondering whether this will be easy to distribute automatically and remotely. I really can't afford to rely on the individual users to install the addin themselves, let alone keep it up to date. Could be a versioning nightmare...

  6. #6
    Registered User
    Join Date
    10-22-2007
    Location
    Mumbai, India
    MS-Off Ver
    MS Excel 2007
    Posts
    59

    Re: Multi-user access to a VBA-application

    I think you can still set a workaround something like when the user tries to save the file run a code which checks a password or a boolean value which needs to be set TRUE only when you want to save the file. If the boolean value is false then nobody can save the file.

    Let me know if this sounds OK.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Multi-user access to a VBA-application

    here's a comprehensive tutorial on creating an addin which can then be deployed on a network or installed on individual machines.

  8. #8
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Multi-user access to a VBA-application

    Whoa, you guys are fast!

    Below is the code I currently use to prevent saving the file, using the password-protected setting "Protect Workbook Structure" as a flag. I'm sure there's a much more elegant way of doing this, but until I find it, this will do:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    
       'prevent the user from saving unauthorized changes
        If ThisWorkbook.ProtectStructure = True Then
            Cancel = True
        Else
            ThisWorkbook.Protect ("mypassword")
        End If
    
    End Sub
    
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    
        'prevent Excel from prompting to save the changes on closing the application
        ThisWorkbook.Saved = True
    
    End Sub

    This works as intended, neutralizing any unwanted attempt at saving. But as I mentioned, it does not prevent Excel from prompting the user to "click Ok and use Save As to save the file with a different name" whenever someone tries to save while in read-only mode. Which obviously isn't actually possible, because of the code preventing any attempt to save, including Save As. Which therefore ensures plenty of emails and phone calls from confused users...


    here's a comprehensive tutorial on creating an addin which can then be deployed on a network or installed on individual machines.
    Thank you for the resource! I'll look into it as soon as possible.

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

    Re: Multi-user access to a VBA-application

    Your last remarks are the best arguments in favour of RoyUk's suggestion.
    An AddIn is the obvious method in this case (and intentionally designed for this purpose).



  10. #10
    Registered User
    Join Date
    04-29-2011
    Location
    Europe
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Multi-user access to a VBA-application

    Judging from that tutorial, I'll have my work cut out for me, but it does indeed seem to be the best solution.

    Thank you all for your advice!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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