Option Base 1
Dim arrHarf()
Sub Word_Doc_Bilgi_Al()
Dim wrd, doc, klasor
Dim m%, i%, x%, y%, j%, durum%
Dim dizin As String, adres As String
Dim arrBaslik()
arrBaslik = Array("TC Kimlik No", "Adı Soyadı", "İkametgah Adresi", "TC Kimlik No", _
"Adı Soyadı", "Doğum Yeri", "Doğum Tarihi", "Eş", "Çocuk", "Erkek", "Kadın", "TC", "İl", "İlçe")
ReDim arrHarf(116)
For i = 1 To 116
If i <= 26 Then arrHarf(i) = Chr(i + 64)
If i > 26 And i <= 53 Then arrHarf(i) = Chr(i + 70)
If i > 53 Then arrHarf(i) = Chr(i + 139)
Next i
y = 1
For i = 1 To UBound(arrBaslik)
Cells(1, i) = arrBaslik(i)
Next i
Set klasor = CreateObject("Shell.Application").BrowseForFolder(0, "Lütfen bir klasör seçin !", &H100)
If klasor Is Nothing Then
MsgBox "Herhangi bir klasör seçmediniz", vbCritical, "UYARI"
Exit Sub
Else
dizin = klasor.Items.Item.Path
End If
Set wrd = CreateObject("Word.Application")
wrd.Application.Visible = True
On Error Resume Next
With Application.FileSearch
.NewSearch
.LookIn = dizin
.FileType = msoFileTypeWordDocuments
.Execute
If .FoundFiles.Count > 0 Then
m = 1
For i = 1 To .FoundFiles.Count
Set doc = wrd.Documents.Open(.FoundFiles(i))
y = y + 1
Cells(y, 1) = Application.WorksheetFunction.Clean(doc.Tables(2).Range.Cells(4))
Cells(y, 2) = Application.WorksheetFunction.Clean(doc.Tables(2).Range.Cells(11))
adres = Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(5))
adres = Mid(adres, 20, Len(adres) - 20 - 28)
Cells(y, 3) = adres 'Mid(Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(5)), 20, 1)
Cells(y, 4) = Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(8))
Cells(y, 5) = Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(11))
Cells(y, 6) = Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(20))
Cells(y, 7) = Application.WorksheetFunction.Clean(doc.Tables(3).Range.Cells(21))
Cells(y, 8) = IIf(doc.FormFields.Item(4).CheckBox.Value = True, 1, 0)
Cells(y, 9) = IIf(doc.FormFields.Item(5).CheckBox.Value = True, 1, 0)
Cells(y, 10) = IIf(doc.FormFields.Item(6).CheckBox.Value = True, 1, 0)
Cells(y, 11) = IIf(doc.FormFields.Item(7).CheckBox.Value = True, 1, 0)
Cells(y, 12) = IIf(doc.FormFields.Item(8).CheckBox.Value = True, 1, 0)
Cells(y, 13) = AdresAyir(adres)
adres = Mid(adres, 1, Len(adres) - Len(Cells(y, 13)))
Cells(y, 14) = AdresAyir(adres)
doc.Close 0
Next i
End If
End With
wrd.Quit
Set klasor = Nothing
Set doc = Nothing
Set wrd = Nothing
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Function AdresAyir(adres As String)
Dim g%, u%, durum%
Dim adr As String
For g = 1 To Len(adres)
For u = 1 To UBound(arrHarf)
If Mid(StrReverse(adres), g, 1) = arrHarf(u) Then durum = durum + 1
Next u
If durum = 0 Then
If Len(adr) > 0 Then
Exit For
End If
Else
adr = adr & Mid(StrReverse(adres), g, 1)
durum = 0
End If
Next g
AdresAyir = Trim(StrReverse(adr))
End Function