orkbook.Worksheets ("База даних"). Visible = False ' показати базу даних
End If
End Sub
Sub ExitProject ()
ThisWorkbook.Saved = True
If Application.Workbooks.count = 1 Then
Application.Quit ' завершити роботу Excel
Else
ThisWorkbook.Close ' завершити роботу проекту
End If
End Sub
Sub dbRead ()
ThisWorkbook.ActiveSheet.Unprotect
Dim myRecord As Record
Dim data As Range, curRow As Range
Dim row As Integer
Range ("A5"). Activate
Set data = ActiveCell.CurrentRegion
data.ClearContents
Open dbFileName For Input As # 1
row = 1
Do While Not EOF (1)
Input # 1, myRecord.Fam, myRecord.Im, myRecord.Ot, myRecord.street, myRecord.no, myRecord.Flat, myRecord.Phone
putRecord ActiveCell.Cells (row), myRecord
row = row + 1
Loop
Close # 1
ThisWorkbook.ActiveSheet.Protect
End Sub
Sub dbWrite ()
ThisWorkbook.ActiveSheet.Unprotect
Dim myRecord As Record
Dim data As Range, curRow As Range
Range ("A5"). Activate
Set data = ActiveCell.CurrentRegion
Open dbFileName For Output As # 1
For Each curRow In data.Rows
myRecord = getRecord (curRow)
Write # 1, myRecord.Fam, myRecord.Im, myRecord.Ot, myRecord.street, myRecord.no, myRecord.Flat, myRecord.Phone
Next curRow
Close # 1
ThisWorkbook.ActiveSheet.Protect
End Sub
Function getRecord (row As Range) As Record
Dim myRecord As Record
myRecord.Fam = row.Cells (, 1). Value
myRecord.Im = row.Cells (, 2). Value
myRecord.Ot = row.Cells (, 3). Value
myRecord.street = row.Cells (, 4). Value
myRecord.no = row.Cells (, 5). Value
myRecord.Flat = row.Cells (, 6). Value
myRecord.Phone = row.Cells (, 7). Value
getRecord = myRecord
End Function
Sub putRecord (row As Range, myRecord As Record)
row.Cells (, 1). Value = myRecord.Fam
row.Cells (, 2). Value = myRecord.Im
row.Cells (, 3). Value = myRecord.Ot
row.Cells (, 4). Value = myRecord.street
row.Cells (, 5). Value = myRecord.no
row.Cells (, 6). Value = myRecord.Flat
row.Cells (, 7). Value = myRecord.Phone
End Sub
Sub showTools ()
Application.CommandBars ("Phones"). Enabled = True
Application.CommandBars ("Phones"). Visible = True
End Sub
Sub hideTools ()
Application.CommandBars ("Phones"). Visible = False
Application.CommandBars ("Phones"). Enabled = False
End Sub
br/>