XL2000: ????? ??????? "??? ???" ?????? ????? ?? ?????

?????? ????????? ?????? ?????????
???? ???????: 213637 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

?? Microsoft Excel? ????? ??????? ?????? ??? ??? ?? Microsoft Visual Basic ??????? ????????? (????? Sub) ??? ?????? ????? ????????? ??????? ????? ??? ?????? ?????? ??????? ?? ?????. ???????? ?????? ??????? ???? ????? ????? ??????? ? ??????? ????? ?? ??????? ?????? ??????? ????? ??? ??????? ??? ?? ????? ???????? ?????.

??? ????? ??????? ?????? ????? ?? ????? ??? ??????? ??? ???? ?????? ?? ??????? ????? ????? ????? ????????? ???????? ???????.

??????? ????

???? Microsoft ??????? ???????? ??? ??? ?? ???? ??????? ?? ?? ????? ? ? ?? ????? ??? ?????? ???????? ??????? ?/?? ???????? ???? ????. ????? ??? ??????? ??? ????? ??? ??? ??????? ???? ?? ????? ???????? ????????? ?????? ????????? ????????. ???? ?? ????? ??????? ????? Microsoft ??? ????? ????? ???? ???? ?? ?????? ?????? ??? ??????? ?????? ????? ?????? ?? ????? ??????? ?????? ????????? ???????.
??? ??? ??? ?? ???? ???? ???? ?????? ?? ???? ???????? ?? ????? ??? ??????? ????? Microsoft ?? ????? ???????. ????? ?? ?????????? ?? ?????? ????? ??? Microsoft ???:

Microsoft ????????? Partners ? https://partner.microsoft.com/global/30000104

????? Microsoft ??????? ???? ???? ??????? - http://support.microsoft.com/gp/advisoryservice

?????? ??? ???? ?? ????????? ??? ?????? ????? ???????? ???? ????? ??????? ????? Microsoft ?? ?????? ???? Microsoft ?????? ??? ?????: http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS?????? ?? ???? ?????? ???????? ????? ?????? ?????? ???????:
   Sub MyMacro()

        On Error GoTo ErrorHandler
        . . .
        Exit Sub

   ErrorHandler:
        . . .
        Resume <or Exit Sub>
        . . .

   End Sub
				
?????? ????? ??? ??????? ???????: ??? ?? ????? (????? GoTo ??? ErrorHandler) "?" ???? ???????. ?? ????? ??? ????? ??????? ??? ????? ?/?? ???? ?????. ??? ??????? ?? ?? ??? ??????? ?????? ???? ?? ??????? ???? ?? ??? ???????.

???? ?? ?? ??? ?????? Sub ????? ????? ???? ????? ????? ???. ???? ???? ????? ?? ???? ????? ??? ??? ?????? ????? ??? ????????? ???????? ?????? ??????? ?? ????? ??? ????? ??????? ??? ?????.

??? ???? ?????

????? ????? ??? ?? ??????? ??????? ??????? ???? ??????? ????? ??. ??? ?? ?????? ????? SQL ??? ??? ?? ??????? ????? ?? ??? ??? ??????? ???? ????: ??? ????? Microsoft Excel ?????? ????? ??? ??? ??????? ? ???? ????? ??????? ??? ???????.

???? ???? ??? ?? ???? ???? ??????? ??????? ??? ???? ??? ??? ?? ???????.
   On Error GoTo <line>
				
????? ????? ?????? ??????? ???? ???? ??? <line>?? ?? ?? ??????? ?? ??? ?????. ??? ?? ???? ??? ?????? ?? ??? ??????? ?????? ?? ?????.
   On Error Resume Next
				
????? ??? ??? ???? ??? ??? ??????? ????? ???? ?????? ??? ??????? ??????? ?????? ??????? ??? ??? ?????. ?????? ????? ????? ???????.
   On Error GoTo 0
				
????? ?? ????? ??????? ???????? ?? ??????? ??????.

???? ?????? ???????

??? ????? ??? ??? ???????? ?????? ??????? ??? ??? ??? ????? ?????? ???????. ?????? ??????? ??? ??? ??? ??? ????? ?????? ??????? ??? ?????? ??? ????? ' End Sub (?? ????? ????) ?? ??????? ???? Sub ????? (?? ????? ????). ?????? ???? ?????? ??? ???? ??? ??? ??????? ?????? ????? ???????.

??????? ??????? ???? ???? ??? ??????? ???? ?? ??? ?? ???????.
   Resume [0]
				
??????? ????? ??????? ?????? ???? ???? ?? ?????. [0] ????? ????????.
   Resume Next
				
??????? ????? ????? ?? ????? ???? ??? ????? ???? ???? ?? ?????.
   Resume <line>
??????? ????? ??????? ??? ??? ????? ?? ????? ????? ?????? ?????? <line>.

??????: ??? ???? ?? ????? ????? ?????? ??????? ??? ??????? ????? ???????? ??? ??????? ?????? ??? ??? ???????? ?????? ???????. ????? ???? ??? ??? ???????? ??????? GoTo ?? ????? ?????? ???????; ??? ??????? ???? ??????? ??????? ????? ??????? ???? ????? ???????.

???? ??? ? ???? ?????

????? ??? ????? ?????? ??????? ???? ?????? ?? ???? ????? ?? ?? ???. ??? ???? ??? ??? ??????? ? ????? ??????? ?????? Err ?????? ??? ?????; ??? ??????? ????? ??? ?????? ??? ???? ???? ??? ?????. ??? ???? ??????? ????? ??????? ??????? ??????? ???? ??? ????? ???? ??? ??????:
   MsgBox Err & ": " & Error(Err)
				
??? ????? ??? ?????? ????? ????? 13 (??? ??? ????? ???) ? ?? ???? ???? ?????? ?? ???? ????:
13: ???? ??? ?????

????? ??? ????? ??????? ???? ??????? ?????? ?????

?? ??? ???????? ?? ??? ??????? ????? ??? ??? ??? ???? ?? ??? ?? ???? ??????? B, ??? ??? ????? ????? ???? ???? B:\XLFiles ?? ??? ??? ???? ?? ??? Book1.xls ?? ?????? B:\XLFiles (??????).

???? 1--??? ????? ???????? ?????

Sub MyMacro()

      Dim MyWorkbook As Workbook

      ' Run the Error handler "ErrHandler" when an error occurs.
      On Error GoTo Errhandler

      ChDrive "B:"
      ChDir "B:\"
      ChDir "B:\XLFiles"
      Workbooks.Open "Book1.xls"

      ' Disable the error handler.
      On Error GoTo 0

      Set MyWorkbook = ActiveWorkbook
      MsgBox "The destination workbook is " & MyWorkbook.Name

      ' Exit the macro so that the error handler is not executed.
      Exit Sub

   Errhandler:

      ' If an error occurs, display a message and end the macro.
      MsgBox "An error has occurred. The macro will end."

   End Sub 
				
?????? ??? ?????? ????? ??? ?? ??? ????? ?????? ????? ??? ???? ???. ??? ??? ??? ?? ???????? ???? ????? ??? ????? ????? ??????? ?? ????? ????? ???????:
??? ???. ???? ????? ???????.
??? ?? ??? ?????? Book1.xls ?????, ??? ????? ????? ?????? ??????? ?????? ??????? ??? ????? Sub ????? ??? ??????? ????? ??? "ErrHandler."

???? 2--??? ?????? ??????? ???? ???? ????? ??? ?????

??? ?????? ?????? ??? ??????? ?? ?????? 1; ??? ???? ???? ??? ??????? ?????? ????? ??? ??????? Err ?????? ????? ??? ????? ???? ??? ?????? ?? ???.
   Sub MyMacro()

      Dim MyWorkbook As Workbook

      ' Run the Error handler "ErrHandler" when an error occurs.

      On Error GoTo Errhandler
      ChDrive "B:"
      ChDir "B:\"
      ChDir "B:\XLFiles"
      Workbooks.Open "Book1.xls"

      ' Disable the error handler.
      On Error GoTo 0

      Set MyWorkbook = ActiveWorkbook
      MsgBox "The destination workbook is " & MyWorkbook.Name

      ' Exit the macro so that the error handler is not executed.
      Exit Sub

   Errhandler:

      Select Case Err

         Case 68, 75:    ' Error 68: "Device not available"
                         ' Error 75: "Path/File Access Error"
            MsgBox "There is an error reading drive B."

         Case 76:        ' Error 76: "Path not found"
            MsgBox "The specified path is not found."

         Case Else:      ' An error other than 68, 75 or 76 has occurred.
            ' Display the error number and the error text.
            MsgBox "Error # " & Err & " : " & Error(Err)

      End Select

      ' End the macro.
   End Sub 

				
??? ??? ??? ?? ??????? ???? ???? ??? ???:
  • ?? ???? ????? 68 ?? 75 ? ???? ????? ??????? ???? ??? "?? ??? ??? ????? ??????? ?? ???? ??????? B" ? ???????.
  • ???? ??? ???? ????? ??? 76 ??????? "?????? ?????? ?? ??? ?????? ???" ?? ??? ????? ???????.
  • ??? ??? ????? ??? ?? 68 ?? 75 76 ??????? "??? < ????? ??? >: < ?? ????? >" ???? ??? ? ???? ????? ???????.
??? ?? ??? ?????? Book1.xls ????? ? ???? ??? ????? ????? ?????? ?????? ?? ???? ????? ??????? ??? ????? Sub ????? ??? ??????? ????? ??? "ErrHandler."

???? 3--????? ????????? ???? ???????

?????? ??? ?????? ?????? ????? ??????? ??????? ????? ????? ???????? ??? ?????????? ???? ???? ???????? ??? ???? ???.
   Sub MyMacro()

   Dim Result as Integer
   Dim ErrMsg as String
   Dim MyWorkbook as Workbook

      ' Run the Error handler "ErrHandler" when an error occurs.
      On Error GoTo Errhandler

      ChDrive "B:"
      ChDir "B:\"
      ChDir "B:\XLfiles"

      Workbooks.Open "Book1.xls"

   NewWorkbook:

      ' Disable the error handler.
      On Error GoTo 0

      Set MyWorkbook = ActiveWorkbook
      MsgBox "The destination workbook is " & MyWorkbook.Name

      ' Exit the macro so that the error handler is not executed.
      Exit Sub

   Errhandler:

      Select Case Err

         Case 68, 75:  ' Error 68: "Device not available"
                       ' Error 75: "Path/File access error
            ErrMsg =  "There is an error reading drive B. Please " & _
               "insert a disk and then press OK to continue or " & _
               "press Cancel to end this operation."

            Result = MsgBox(ErrMsg, vbOKCancel)

            ' Resume at the line where the error occurred if the user
            ' clicks OK; otherwise end the macro.
            If Result = vbOK Then Resume

         Case 76:     ' Error 76: Path not found
            ErrMsg = "The disk in drive B does not have an XLFiles " & _
               "directory. Please insert the correct disk."

            Result = MsgBox(ErrMsg, vbOKCancel)

            ' Resume at the line where the error occurred if the user
            ' clicks OK; otherwise end the macro.
            If Result = vbOK Then Resume

         Case Else:   ' A different error occurred.

            ErrMsg = "An error has occurred opening " & _
                 "B:\XLFiles\Book1.xls. Use the active workbook as " & _
                 "the destination?"

            Result = MsgBox(ErrMsg, vbYesNo)

            ' Resume at the label "NewWorkbook" if the user clicks Yes;
            ' otherwise end the macro.
            If Result = vbYes Then Resume NewWorkbook

      End Select

   ' End the macro.
   End Sub 

				
??? ?? ??? ?????? Book1.xls ????? ? ???? ??? ????? ????? ?????? ?????? ???? Book1.xls ?? ???? ????? ??????? ??? ????? Sub ????? ??? ??????? ????? ??? "ErrHandler." ??? ??? ??? ?? ??????? ????? ????? ??????? ???? ??? ????????? ???????:
  • ?? ???? ????? 68 ?? 75 ? ??? ??? ??????? ???????:
    ???? ??? ?? ????? ???? ??????? B. ?????? ????? ??? ?? ???? ??? ????? ???????? ?? ???? "????? ?????" ?????? ??? ???????.
    ?? ???? ???? ???????? ?????? ??? ????? ?? ???? ?????? ??? ??????? ??????? ?? ??? ??? ??? ?????. ?? ???? ???? ???????? ?????? ??? ????? ???? ????? ???????.
  • ???? ????? ??? 76 ?? ??????? ??? ??? ??? ???????
    ?? ??? ????? ?? ???? ??????? B ????? XLFiles. ?????? ????? ????? ??????.
    ?? ???? ???? ???????? ?????? ??? ????? ?? ???? ?????? ??? ??????? ??????? ?? ??? ??? ??? ?????. ?? ???? ???? ???????? ?????? ??? ????? ???? ????? ???????.
  • ???? ????? ??? ??? ?? 68 ?? 75 ?? 76 ?? ????? ????? ??????? ??? ???
    ??? ??? ??? ????? ??? B:\XLFiles\Book1.xls. ??????? ?????? ????? ????? ?
    ???? ???????? ?????? ??? ??? ?? ???? ?????? ? ??????? ??????? ?? ??? ??????? "NewWorkbook." ??? ??? ?????? ????? ?????? ?? ?????? ??????. ?? ???? ???? ???????? ?????? ??? "??" ? ???? ????? ???????.

???? 4--????? ???????? ?????? ?????

????? ????? ??? ????? ????????? ???????? ?? ??????? ????? ?? ????? ???????? ?????? ?????. ?????? sign ???? ????? ?????? ????? ?? ???? ????? ???? ?? ???? ?? ????????? ???? ?????? ??????? ???????.

?????? ?? ????? ??????? ErrorHandling ???? ??? ????? ???????? ??? ??? ????? (ErrorValue) ???? ?? ??????? ????? ?? ????? ???? ? ?????? ???????? ??????? ?? ?????? ??? ?? ??? ????? ?? ????? ???? ?????. ???????? ??? ?????? ???? ???? ???????? ??????? ErrorHandling ???? ???? (ReturnValue) ?????? ????????? ??????? ??? ????? ?????????. ???? ?? ???? ReturnValue Err_Exit (????? ??????? ??? ??? ?????) ?? Err_Resume (??????? ?? ????? ?? ??????? ??? ??? ?????) Err_Resume_Next (??????? ?? ????? ???? ??? ????? ?? ??????? ??? ??? ?????).
   Public Const Err_Exit = 0
   Public Const Err_Resume = 1
   Public Const Err_Resume_Next = 2

   Sub ErrorHandling(ErrorValue As Integer, ReturnValue As Integer)

      Dim Result as Integer
      Dim ErrMsg as String
      Dim Choices as Integer

      Select Case ErrorValue

         Case 68:     ' Device  not available.

            ErrMsg = "The device you are trying to access is either " & _
               "not online or does not exist. Retry?"
            Choices = vbOKCancel

         Case 75:     ' Path/File access error.

            ErrMsg = "There is an error accessing the path and/or " & _
                 "file specified. Retry?"
            Choices = vbOKCancel

         Case 76:     ' Path not found.

            ErrMsg = "The path and/or file specified was not found. Retry?"
            Choices = vbOKCancel

         Case Else:   'An error other than 68, 75 or 76 has occurred

            ErrMsg = "An unrecognized error has occurred ( " & _
               Error(Err) & " ). The macro will end."
            MsgBox ErrMsg, vbOKOnly
            ReturnValue = Err_Exit
            Exit Sub

      End Select

      ' Display the error message.
      Result = MsgBox(ErrMsg, Choices)

      ' Determine the ReturnValue based on the user's choice from MsgBox.
      If Result = vbOK Then
         ReturnValue = Err_Resume
      Else
         ReturnValue = Err_Exit
      End If

   End Sub 
				
???? ??? ??????? ?????? ??? ????? ??????? ??????? ErrorHandling ??? ?????? ?? ???:
   Sub MyMacro()

      Dim Action As Integer

      ' Run the Error handler "ErrHandler" when an error occurs.
      On Error GoTo Errhandler

      ChDrive "B:"
      ChDir "B:\"
      ChDir "B:\XLFiles"
      Workbooks.Open "Book1.xls"

      ' Exit the macro so that the error handler is not executed.
      Exit Sub

   Errhandler:

      ' Run the ErrorHandling macro to display the error and to
      ' return a value for Action which will determine the appropriate
      ' action to take (Resume the macro or end the macro)

      ErrorHandling Err, Action

      If Action = Err_Exit Then
         Exit Sub
      ElseIf Action = Err_Resume Then
         Resume
      Else
         Resume Next
      End If

   End Sub 
				

?????

?????? ??? ???? ?? ????????? ??? ?????? ??????? ?? amacro ?? ???? Visual Basic? ???? ??? "??????? Microsoft Visual Basic" ?? ??????? ??????? ? ???? ?? "???? ????? ?? ????? Office" ?? "????? ??????? ?? ???? ??? ??? ???? ???????.

?????? ??? ??????? ?????? ??? ?????? ??? ??????? ??? forApplications Visual Basic "? ???? ??? ??? ??????? ????? ?????? ??" ????? ??????? ?? Microsoft:
226118OFF 2000: ????? ????? Visual Basic ?????????

???????

???? ???????: 213637 - ????? ??? ??????: 02/?? ??????/1427 - ??????: 3.5
????? ???
  • Microsoft Excel 2000 Standard Edition
????? ??????: 
kbmt kbdtacode kbhowto kbprogramming KB213637 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????213637

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com