Private Type Employee
empID As String*8
empName As String*20
empAge As Integer
empStatus As String*10
empSalaryClass As String*1
End Type
Private recNum As Integer
Sub WriteEmployeeInfo()
Dim empData As Employee
Dim filePath As String
recNum = GetMaxRecNum 'Get the next available record number
filePath = ActiveWorkbook.Path & "\Employees.txt"
Open filePath For Random As #1 Len = Len(empData) 'Open file
empData.empID = Cells(2, "A").Value
empData.empName = Cells(2, "B").Value
empData.empAge = Cells(2, "C").Value
empData.empStatus = Cells(2, "D").Value
empData.empSalaryClass = Cells(2, "E").Value
Put #1, recNum, empData 'Write the data
Close #1
End Sub
'
|