Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form
Multiple users updating Excel from windows form Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Go Back  Xtreme Visual Basic Talk > > > Multiple users updating Excel from windows form


Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2016, 12:05 AM
av123 av123 is offline
Newcomer
 
Join Date: Nov 2016
Posts: 2
Default Multiple users updating Excel from windows form


have created a form in Visual Studio 2013 which is used to enter data in Excel by multiple users at same time. It works perfectly fine except if two users open form at the same time or if one has clicked submit and the form is still processing. Then it shows the following error for the other person.

Quote:
Unhandled exception has occurred in your application. Exception from HRESULT: 0x800A03EC
Any help on how I can rectify this?

Code:
Imports excel = Microsoft.Office.Interop.Excel
Imports System.Runtime.InteropServices

Public Class Form1
    Dim xlapp As New excel.Application
    Dim workbook As excel.Workbook
    Dim worksheet As excel.Worksheet

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
        workbook = xlapp.Workbooks.Open("2.xlsx")
        xlapp.Visible = False
        worksheet = workbook.Sheets("sheet1")
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If workbook.MultiUserEditing Then
            workbook.AcceptAllChanges()
            workbook.Save()
        End If

        Dim row As Long
        Dim alpha As Long = 0
        row = 5
        With worksheet
            Do While .Cells(row, 4).value IsNot Nothing
                row = row + 1
            Loop

            .Cells(row, 2).value = Me.fname.Text
            .Cells(row, 3).value = Me.lname.Text
            Me.fullname.Text = Me.fname.Text + Me.lname.Text
            .Cells(row, 4).value = Me.fullname.Text
        End With
        xlapp.DisplayAlerts = False
        workbook.SaveAs("2.xlsx", AccessMode:=excel.XlSaveAsAccessMode.xlShared)
    End Sub
End Class
Reply With Quote
Reply

Tags
dim, row, .cellsrow, form, excel, users, worksheet, imports, class, workbook, exception, object, private, eventargs, multiple, handles, false, 4.value, me.lname.text, me.fname.text, me.fullname.text, time, 2.value, xlapp, form1_loadsender


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
 
Multiple users updating Excel from windows form
Multiple users updating Excel from windows form
 
-->