+ Reply to Thread
Results 1 to 4 of 4

Sharing excel file on LAN

Hybrid View

  1. #1
    Registered User
    Join Date
    12-20-2008
    Location
    Mumbai
    MS-Off Ver
    Microsoft Office 2003 and 2007
    Posts
    36

    Sharing excel file on LAN

    I have an excel file with a userform which is used to input data.

    Whenever the userform is initialized, a sr No(In a textbox) is automatically generated based on the max value in column A.The user then enter other data as per the fields in the userform.

    When the submit(Command button) is pressed the data is enter in an excel sheet of the same workbook.

    I want to share this workbook over my LAN and allow different users to edit at the same time.

    The problem is when two users are accessing the workbook at the same time,the Sr No generated is same for both of them.

    Now when user 1 saves the file the data is recorded in the worksheet, but when user 2 saves the file, the data gets overwritten and only what user 2 has recorded gets saved.

    How to overcome this problem.

    Workbook Attached.
    Last edited by VBA Noob; 01-29-2009 at 04:32 PM.

  2. #2
    Registered User
    Join Date
    12-20-2008
    Location
    Mumbai
    MS-Off Ver
    Microsoft Office 2003 and 2007
    Posts
    36

    Sharing excel file on LAN

    here is the attached workbook
    The password to open the code is
    "a"
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-20-2008
    Location
    Mumbai
    MS-Off Ver
    Microsoft Office 2003 and 2007
    Posts
    36

    Re: Sharing excel file on LAN

    Someone Please help.
    Atleast tell if it is possible or not

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: PLease help:Sharing excel file on LAN

    Hello karthikcoep,

    The way to do this is keep the serial number in a separate file. This provides exclusive user access as only one user can have the file open at a time. It also allows all users to read and write the same serial number. The serial number file is a single line text file that can be stored on the server. Create the file using NotePad and enter the current serial number and save the file where you and others can access it. Change the string variable SNfile in the macro to the path of this file (include the file name and extension with the path). Here are the 2 macro to get the serial number and update it. The text box for the serial number has its Locked property set to True. This allows only the code to change the serial number and not the user.
    Function GetSN()
    
      Dim FSO As Object
      Dim SN As Double
      Dim SNfile As Variant
      Dim TS As Object
      
        SNfile = "C:\Documents And Settings\Admin.ADMINS\My Documents\Query Serial Number.txt"
        
        Set FSO = CreateObject("Scripting.FileSystemObject")
        Set TS = FSO.OpenTextFile(SNfile, 1, True, -2)
        
          GetSN = TS.ReadLine
        
        TS.Close
        Set FSO = Nothing
        
    End Function
    
    Sub UpdateSN()
    
      Dim FSO As Object
      Dim SN As Variant
      Dim SNfile As String
      Dim TS As Object
      
        SNfile = "C:\Documents And Settings\Admin.ADMINS\My Documents\Query Serial Number.txt"
        
        Set FSO = CreateObject("Scripting.FileSystemObject")
        
          Set TS = FSO.OpenTextFile(SNfile, 1, False, -2)
            SN = TS.ReadLine
          TS.Close
          
          Set TS = FSO.OpenTextFile(SNfile, 2, False, -2)
            TS.WriteLine SN + 1
          TS.Close
          
        Set FSO = Nothing
        Set TS = Nothing
    
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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