¥»©«³Ì«á¥Ñ starry1314 ©ó 2015-8-5 11:22 ½s¿è
¥Ø«e¥i¥¿±`§PÂ_Àɮת¬ºA,¦ý¤£ª¾¦p¦óקï¥iÅý¦b¥¼¶}±Òª¬ºAªº®ÉÔ °õ¦æ- Workbooks.Open "\\«ÈªA\«È¤áºûÅ@°Ï\A°Ï\«È¤á©ú²Ó.xlsm"
½Æ»s¥N½X ¶·©ñ¦b Sub ¶}±ÒA°Ï() ¤º,©Î¬O¦AMsgBox "ÀÉ®×" & IIf(IsFileOpen(strPath), "¥L¤H¨Ï¥Î¤¤,¤£¥i¶}±Ò", "¥¼¾D¥L¤H¶}±Ò,¥i¨Ï¥Î") ¥i³]©w¤£¥i¶}±Ò«hµ²§ôµ{¦¡,
¥i¨Ï¥Î«hÄ~Äò°õ¦æ¤U¤@¨B«h¥i±N¶}±ÒÀɮשñ¦b¤U¤@¬q- Sub ¶}±ÒA°Ï()
- Dim strPath As String
- strPath = "\\«ÈªA\«È¤áºûÅ@°Ï\A°Ï\«È¤á©ú²Ó.xlsm"
- If Len(Dir(strPath)) = 0 Then
- Workbooks.Open "\\«ÈªA\«È¤áºûÅ@°Ï\A°Ï\«È¤á©ú²Ó.xlsm"
-
- Else
- MsgBox "ÀÉ®×" & IIf(IsFileOpen(strPath), "¥L¤H¨Ï¥Î¤¤,¤£¥i¶}±Ò", "¥¼¾D¥L¤H¶}±Ò,¥i¨Ï¥Î")
- End If
- End Sub
½Æ»s¥N½X- Function IsFileOpen(strFile As String) As Boolean
- Dim iFile As Integer
- Dim iErr As Integer
-
- On Error Resume Next
- iFile = FreeFile()
- Open strFile For Input Lock Read As #iFile '¥HÂê©w¤è¦¡¶}±Ò¡A¶}±Ò«ü©wÀɮ׫᪽±µÃö³¬ÀÉ®×
- Close iFile
-
- iErr = Err '±N¿ù»~¸¹½X±a¤JiErrÅܼƤ¤¡AµM«á¨Ì·Ó¼Æ¦r§Y¥i±oª¾Àɮת¬ºA
- On Error GoTo 0
- Select Case iErr
- Case 0
- IsFileOpen = False
-
- Case 70
- IsFileOpen = True
- Case 53
- MsgBox "§ä¤£¨ìÀɮסA½Ð¦A½T»{¡I"
- IsFileOpen = False
- Case 76
- MsgBox "§ä¤£¨ì¸ô®|¡A½Ð¦A½T»{¡I"
- IsFileOpen = False
- End Select
- End Function
½Æ»s¥N½X |