Компьютерная подготовка
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