|
>あつかましいのですが、できましたらその部分の一例を教えてほしいのですが
>よろしくおねがいします。
標準モジュールに
−−−−−−−−−−−−−−−−−−−−−−−−−−−
Option Explicit
Public oldtime As Date
Public Sub Auto_Open()
If Not ThisWorkbook.ReadOnly Then
On Error Resume Next
If Not ThisWorkbook.Saved Then
Application.EnableEvents = False
ThisWorkbook.Save
Application.EnableEvents = True
End If
ThisWorkbook.ChangeFileAccess Mode:=xlReadOnly
End If
oldtime = FileDateTime(ThisWorkbook.FullName)
Application.OnTime Now, "updchk"
End Sub
Public Sub updchk()
Dim newtime As Date
newtime = FileDateTime(ThisWorkbook.FullName)
If oldtime <> newtime Or Not ThisWorkbook.Saved Then
On Error Resume Next
If ThisWorkbook.ReadOnly Then
Application.OnTime Now, "Auto_Open"
ThisWorkbook.ChangeFileAccess Mode:=xlReadWrite
Exit Sub
End If
oldtime = newtime
End If
Application.OnTime Now + TimeSerial(0, 0, 5), "updchk"
End Sub
−−−−−−−−−−−−−−−−−−−−−−−−−−−
ってな感じですが、うまくないですね。
やはり、プログラムとデータは別ファイルにすべきかと。
|
|