2016-11-10 110 views
0

我有一個在Visual Studio 2013中創建的窗口應用程序窗體。我需要從窗體輸入數據到excel工作表,直到用戶關閉窗體。該工作簿將由多個用戶同時共享。此外,我不希望他們看到工作簿,除非他們打開它。工作簿共享vb.net

我該怎麼做?

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click 
    xlWorkBook = xlApp.Workbooks.Open("C:\1.xlsx") 
    xlWorkSheet = xlWorkBook.Sheets("Sheet1") 
    Dim iRow As Long 
    Dim alpha As Long = 0 
    iRow = 5 
    With xlWorkSheet 
     Do While .Cells(iRow, 2).value <> "" 
      iRow = iRow + 1 
     Loop 

     .Cells(iRow, 2).Value = t1.Text 
     .Cells(iRow, 3).Value = t2.Text 
     .Cells(iRow, 5).Value = t3.Text 
    End With 
    xlApp.DisplayAlerts = False 
    xlWorkBook.Save() 
End Sub 

回答