ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

¦p¦ó§PÂ_ server ¤Wªº excel Àɮ׳Q¶}±Ò

¦p¦ó§PÂ_ server ¤Wªº excel Àɮ׳Q¶}±Ò

¦³¤H¥i¥H¸Ñµª¤@¤U, ­n¦p¦ó§PÂ_ server ¤Wªº excel Àɮ׳Q¶}±Ò
­ì¦]¬O¦]¬°¦p server ¤Wªº excel³Q§O¤H¶}±Ò«á,
­n§PÂ_¬O§_¯à±N¸ê®Æ¦s¤J¨ì server ¤Wªº excel ÀÉ®×
­Y³Q§O¤H¶}±Ò, «h¸õ¥X message ³qª¾ Àɮפv³Q¶}±Ò, ¨Ã©ñ±ó¦sÀÉ
excel VBA ¥i¥H°µªº¨ì¶Ü?

¥Ø«e­ì¥»´N·|¦Û°Ê´N·|§PÂ_§r , ¦pªG¦³¤H¶}±Ò, ´N¥u¯à¥Î°ßŪ¥´¶}

¦pªG­n¦Û¤v¥´³y, ´N²£¥Í­Ó lock file ¥h¨Ñ§PÂ_´N¦n¤F

TOP

·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

·Q½Ð°Ý GBKEE ª©¥D
  ©³¤U¦³¨Ç¤£¤ÓÀ´, ¥i¥H¸Ñµª¤@¤U¶Ü

Sub SetAttribue()
Dim strFile As String
strFile = "c:\temp\test.xlsx"
If Not IsWorkBookOpen(strFile) Then
      SetAttr strFile, vbReadOnly                 ' ¤£¤ÓÀ´³oÃ䪺·N«ä

      MsgBox "file now readonly"
    Else
        MsgBox "File is already open"
    End If
End Sub

Function IsWorkBookOpen(FileName As String) As Boolean
    Dim ff As Long
    Dim ErrNo As Long

    On Error Resume Next
    ff = FreeFile()                                                                   ' ¤£À´»yªk
    Open FileName For Input Lock Read As #ff   ' ¤£À´ #ff ·N«ä
    Close ff
    ErrNo = Err
    On Error GoTo 0


    Select Case ErrNo
    Case 0:    IsWorkBookOpen = False
    Case 70:   IsWorkBookOpen = True
    Case Else: Error ErrNo
    End Select
End Function

TOP

¦^´_ 2# diolin


   §Úª¾¹D¥i¥H¶}ªº°_¨Ó, ¦ý³Q§O¤H¶}±Ò«á§Ú¤S­n¦sÀÉ´N·|¦³°ÝÃD°Ú
   ©Ò¥H¤~­n¤@¶}±ÒÀÉ®×,´N§PÂ_Àɮ׬O§_³Q§O¤H¶}±Ò
   ³o¹ï¦h¤H¥i¯à¦P®É¨Ï¥Î¤@­ÓÀÉ®×, ¦³«Ü¤jªºÃö«Y

TOP

¦^´_ 3# GBKEE
·Q½Ð°Ý GBKEE ª©¥D
  ©³¤U¦³¨Ç¤£¤ÓÀ´, ¥i¥H¸Ñµª¤@¤U¶Ü

Sub SetAttribue()
Dim strFile As String
strFile = "c:\temp\test.xlsx"
If Not IsWorkBookOpen(strFile) Then
      SetAttr strFile, vbReadOnly                 ' ¤£¤ÓÀ´³oÃ䪺·N«ä
      MsgBox "file now readonly"
    Else
        MsgBox "File is already open"
    End If
End Sub

Function IsWorkBookOpen(FileName As String) As Boolean
    Dim ff As Long
    Dim ErrNo As Long

    On Error Resume Next
    ff = FreeFile()                                                                   ' ¤£À´»yªk
    Open FileName For Input Lock Read As #ff   ' ¤£À´ #ff ·N«ä
    Close ff
    ErrNo = Err
    On Error GoTo 0

    Select Case ErrNo
    Case 0:    IsWorkBookOpen = False
    Case 70:   IsWorkBookOpen = True
    Case Else: Error ErrNo
    End Select

TOP

        ÀR«ä¦Û¦b : ¨Ã«D¦³¿ú¾{¬O§Ö¼Ö¡A°Ý¤ßµL·\¤ß³Ì¦w¡C
ªð¦^¦Cªí ¤W¤@¥DÃD