[CODE]Public Function FileFolderExists(strFullPath As String) As Boolean
On Error GoTo EarlyExit
If Not Dir(strFullPath, vbDirectory) = vbNullString Then FileFolderExists = True
EarlyExit:
On Error GoTo 0
End Function
Private Sub Document_Close()
Dim veri As Variant
Application.ScreenUpdating = False
dosyaadi = ThisDocument.Name
veri = Array("")
If FileFolderExists(Mid(ThisDocument.Path, 1, Len(ThisDocument.Path)) & "\kontrol.docx") Then
Documents.Open FileName:=Mid(ThisDocument.Path, 1, Len(ThisDocument.Path)) & "\kontrol.docx"
If ActiveDocument.Name = "kontrol.docx" Then
Selection.TypeText Format(Now, "dd.mm.yyyy HH:nn:ss") & " | " & Environ("Computername") & " | " & dosyaadi & " | KAPATILDI"
Selection.TypeParagraph
ActiveDocument.Save
ActiveDocument.Close
End If
Else
For i = 1 To Len(ThisDocument.Path)
If Mid(ThisDocument.Path, i, 1) = "\" Then
If i = Len(ThisDocument.Path) Then
veri(UBound(veri)) = veri(UBound(veri)) & i
Else
veri(UBound(veri)) = veri(UBound(veri)) & i
ReDim Preserve veri(UBound(veri) + 1)
End If
End If
Next i
For i = UBound(veri) - 1 To LBound(veri) Step -1
If FileFolderExists(Mid(ThisDocument.Path, 1, veri(i)) & "kontrol.docx") Then
Documents.Open FileName:=Mid(ThisDocument.Path, 1, veri(i)) & "kontrol.docx"
If ActiveDocument.Name = "kontrol.docx" Then
Selection.TypeText Format(Now, "dd.mm.yyyy HH:nn:ss") & " | " & Environ("Computername") & " | " & dosyaadi & " | KAPATILDI"
Selection.TypeParagraph
ActiveDocument.Save
ActiveDocument.Close
End If
End If
Next i
End If
Application.ScreenUpdating = True
End Sub
Private Sub Document_Open()
Dim veri As Variant
Application.ScreenUpdating = False
dosyaadi = ThisDocument.Name
veri = Array("")
If FileFolderExists(Mid(ThisDocument.Path, 1, Len(ThisDocument.Path)) & "\kontrol.docx") Then
Documents.Open FileName:=Mid(ThisDocument.Path, 1, Len(ThisDocument.Path)) & "\kontrol.docx"
If ActiveDocument.Name = "kontrol.docx" Then
Selection.TypeText Format(Now, "dd.mm.yyyy HH:nn:ss") & " | " & Environ("Computername") & " | " & dosyaadi & " | AÇILDI"
Selection.TypeParagraph
ActiveDocument.Save
ActiveDocument.Close
End If
Else
For i = 1 To Len(ThisDocument.Path)
If Mid(ThisDocument.Path, i, 1) = "\" Then
If i = Len(ThisDocument.Path) Then
veri(UBound(veri)) = veri(UBound(veri)) & i
Else
veri(UBound(veri)) = veri(UBound(veri)) & i
ReDim Preserve veri(UBound(veri) + 1)
End If
End If
Next i
For i = UBound(veri) - 1 To LBound(veri) Step -1
If FileFolderExists(Mid(ThisDocument.Path, 1, veri(i)) & "kontrol.docx") Then
Documents.Open FileName:=Mid(ThisDocument.Path, 1, veri(i)) & "kontrol.docx"
If ActiveDocument.Name = "kontrol.docx" Then
Selection.TypeText Format(Now, "dd.mm.yyyy HH:nn:ss") & " | " & Environ("Computername") & " | " & dosyaadi & " | AÇILDI"
Selection.TypeParagraph
ActiveDocument.Save
ActiveDocument.Close
End If
End If
Next i
End If
Application.ScreenUpdating = True
End Sub