Microsoft Office Excel ® Kod Kılavuzu

Microsoft Office Excel® Code Guide

1 Mayıs 2007 Salı

Log File Creation



'Sheet(Sayfa1)

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

On Error Resume Next
Set Alan = Application.Selection
For Each Hücre In Alan.Cells
Call LogDosyaYaz(Hücre.Address & ":" & Hücre.FormulaR1C1)
Next Hücre
End Sub
Sub LogDosyaYaz(HücreVeri)
'Write Log File

On Error Resume Next
FL = ThisWorkbook.Path & Application.PathSeparator & ThisWorkbook.Name & ".LOG"
TS = VBA.Format(Date, "d mmm yy") & " at " & VBA.Format(Time, "hh:mm am/pm")
If (VBA.Len(TS) = 21) Then
TS=""
Else
TS = Application.Rept(" ", 21 - VBA.Len(TS)) & TS'TarihKontrol
End if
FN = VBA.FreeFile()
If VBA.Dir(FL) = "" Then
Open FL For Append As #FN
Print #FN, "Opened: " & TS
Close #FN
End If
Open FL For Append As #FN
Print #FN, TS & ": " & HücreVeri
Close #FN
End Sub

'Module1

Option Explicit
Public RV As Double
'KayıtPublic Alan As Range, Hücre As Range
Public FN
'File Number
Public FL
'Log File
Public TS
'Time Serial

Sub LogDosyaAç() 'OpenLogFile
On Error Resume Next
FL = ThisWorkbook.Path & Application.PathSeparator & ThisWorkbook.Name & ".LOG"
If VBA.Dir(FL) = "" Then
MsgBox "Geçerli bir dosya bulunamadı!" & vbCrLf & vbCrLf & "Mustafa ULUSARAÇ" & vbCrLf & "01ulusarac@superonline.com", vbOKOnly, "[PBİD®] Log File "
Else
RV = VBA.Shell("NOTEPAD.EXE" & " " & FL, 3)
End If
End Sub

Hiç yorum yok:

Blog Arşivi

Bu gadget'ta bir hata oluştu

Bu Blogda Ara

Contributor

Contributor
Mustafa ULUSARAÇ İstanbul, TÜRKİYE
free counters
T. C. Central Bank Indicative Exchange Rates
Currency Exchange Rate Widget,Currency Converter Widget
Borsa İstanbul