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

ÀˬdÀɮ׬O§_¦s¦b

ÀˬdÀɮ׬O§_¦s¦b

½Ð°Ýµ{¦¡¦p¦ó¥HIF ¥hÀˬd
ÀÉ®×TEST.XLS ¬O§_¦s¦b©ó C:\

¤Î
ÀÉ®× TEST1.XLS ¬O§_¤w¶}±Ò

½Ð«ü±Ð

If Dir("C:\TEST.XLS") = Empty Then
     MsgBox "¤å¥ó¤£¦s¦b¡C"
   End If
   On Error Resume Next
   Set B = Workbooks("TEST.XLS")
If Err.Number = 0 Then
        MsgBox testfile & "Àɮפw¶}±Ò"
    End If

TOP

½Ð°Ýµ{¦¡¦p¦ó¥HIF ¥hÀˬd
ÀÉ®×TEST.XLS ¬O§_¦s¦b©ó C:\

¤Î
ÀÉ®× TEST1.XLS ¬O§_¤w¶}±Ò

½Ð«ü±Ð
enoch µoªí©ó 2011-7-27 14:13



³o­Ó¥i¬d¤£¦PEXCEL¶iµ{
°Ñ¦Ò: http://support.microsoft.com/kb/209189/zh-tw

Sub test()
    Dim result As Integer
    result = FileLocked("C:\TEST.XLS")
    Select Case result
     Case Is = 76
        MsgBox ("¸ô®|¤£¦s¦b¡C")
     Case Is = 75
        MsgBox ("¤å¥ó¤£¦s¦b¡C")
     Case Is = 70
        MsgBox ("Àɮפw¶}±Ò")
     Case Is = 0
        MsgBox ("ÀÉ®×¥¿±`")
    Case Else
        MsgBox ("Àɮצ³¤£©ú°ÝÃD")
    End Select
End Sub
Function FileLocked(strFileName As String) As Integer
   On Error Resume Next
   Open strFileName For Binary Access Read Write Lock Read Write As #1
   Close #1
   FileLocked = Err.Number
   If Err.Number <> 0 Then
    Err.Clear
   End If
End Function
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

  1. Sub Ex()
  2.     Dim F As Boolean
  3.     F = CreateObject("Scripting.FileSystemObject").FileExists("D:\TEST.XLS")
  4.     If F = False Then MsgBox "§ä¤£¨ìÀÉ®× ??"
  5. End Sub
½Æ»s¥N½X

TOP

ÁÂÁ±оÇ,§Ú¥¿¦n´M§äÃþ¦ü°ÝÃDªºvba¼gªk
Thanks!

TOP

        ÀR«ä¦Û¦b : ¬Ý§O¤H¤£¶¶²´¡A¬O¦Û¤v­×¾i¤£°÷¡C
ªð¦^¦Cªí ¤W¤@¥DÃD