????? ????? subroutines ?????? ??????? ?? Visual Basic ?? Excel 2000 ?? Excel 2002

???? ???????: 213837 - ??? ???????? ???? ????? ????? ??? ???????.

Microsoft Excel 97 ?? ????? ???? ?? ??? ???????? ???? 108519.
????? ???? | ?? ????

?? ??? ??????

??????

?? Microsoft Excel? ????? ????? Microsoft Visual Basic ??????? ??????? Sub ? ????? ????? Microsoft Excel ??????? 4.0 ?? ????? Visual Basic ?????? ??????? ?????? Application.Run ? Application.ExecuteExcel4Macro. ????? ????? ????? ??????? Visual Basic Sub ?? ????? ??????? ?? ?????? ????? ??? ????? ??? ??? ??????.

???? ??? ??????? ?????? ?? ????? ???? ????? ????????? ?????? ????????? ??????? ?????? ????? Microsoft Excel ??????? 4.0 ?? Visual Basic ?? Microsoft Excel.

??????? ????

???? 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

??????? 1: Application.Run

????? ??????? ??????? Application.Run ????? ??????? Visual Basic Sub ?? ????? ????? Microsoft Excel ??????? 4.0 ?? ??????? Visual Basic ??????. ????? ??????? Application.Run ??????? ??????? ????: ??? ????? ?? ????? Sub ?????. (??? ????? ?? ???? ?????? ?????? ???????? ??? ???? ?????.) ???? ?? ???? ??? ????? ??? ????? ???? (??? ???? ??????? "TestXLM") ?? ???? ?? ???? ????? ????? ??? ???????.

?????? 1: ????? ??

?????? ????? Microsoft Excel ??????? 4.0 ???? TestXLM ????? ??????? ??? ??????? ??????:
Application.Run "TestXLM"
				

??? ?????? 2: ?????

??? ??? ???? ????? ????? "MacroToRun" ??? "TestXLM" ? ????? ??????? ??? ???????:
Application.Run MacroToRun
				

??????? 2: Application.ExecuteExcel4Macro

????? ????? ??????? ??????? Application.ExecuteExcel4Macro ????? ????? ????? Microsoft Excel ??????? 4.0 ?? ??????? Visual Basic Sub ?????? ???? ???? ?????? ????? ??? ?? ??. ???????? Application.ExecuteExcel4Macro ?????? ???? ????? ?? ????? Sub ??? ???? ????? ????? ?????? () Microsoft Excel ??????? 4.0 ????? ??? ?? ??????? ???????:
Application.ExecuteExcel4Macro "RUN(""TestXLM"")"
				
  -or-
				
Application.ExecuteExcel4Macro "RUN(""" & MacroToRun & """)"
				
??? ??????? Application.ExecuteExcel4Macro ??? ???? ??????? ?????? ????????. ??? ???? ??????? ???????? ?????? () ????? ??? ???? ????? ??? ??????? ??? ?????? ??????:
RUN("TestXLM")
				
?? ??? ??? ??????? ??????? ??? ?????? ??????. ??? ????? ?????? ?????? ??? ???? ??????? ??? ????? ????? ?????? ?????? ?????? ??? ????? ?????? ??? ???????:
"RUN(""TestXLM"")"
				
????? Application.ExecuteExcel4Macro ?????? ????? ???? ?????? () ????? ???? ??????? ?? ????? Application.Run ??????. ????? ?????? ???? ???? ??? ????? ????? ??????? ??:
"RUN(""" & MacroToRun & """)"
				
??? ??????? ??? ?????
RUN("" & MacroToRun & "")
				
??? ??? ????? ????? Microsoft Excel ??????? 4.0.

??????? ???????: ????? ??????

?? ??? ??????? ????? ??????? ??? ????? ??????? Visual Basic Sub ???? ?? ????? ????? Microsoft Excel ??????? 4.0. ??? ???? ??????? ?????? ????? SubTestVBSub ?? ???????? ???? ???????:
Call TestVBSub
				
?? ???? ????? ??? ????? ??? ??????? ??????. ??? ???? ??????? ??? ??? ???? ????? ????? "SubToRun" ??? "TestVBSub" ? ?? ????? ????? ????? TestVBSub Sub ?? ??????:
Call SubToRun
				

????? ???????: ????? Sub ??????? ??? ????? ?????

???? ????? ????? Visual Basic Sub ?????? ????? ???? ??? ??? ??????. ??? ???? ??????? ??? ??? ???? ????? Sub ????? ?? ?????? ??????? ?????? TestVBSub ?????? ??????
TestVBSub
				
??? ??? ??????. ??? ????? ??? ????? ?? ??????? ?????? ????? ????? ???? TestVBSub.

??????? ???????: ??????? ????? Visual Basic

?????? ????????? ??????? ????? ????? ???????? ?????? ?????? ???? ????? ????????? ????? ????? Visual Basic Sub ?? ????? Microsoft Excel ??????? 4.0 ?? ????? Visual Basic ??? ???? ??????? ???????:
  1. ?? ???? ???? ????? ???? ????? Microsoft Excel 4.0 ???? ?????1 ? ???? ????? Visual Basic ???? ?????? ??????? 1.

    ??????: ?????? ???? ????? Visual Basic ?? Microsoft Excel ???? ALT + F11 ?????? ???? Visual Basic. ?? ???? ??? ?????? ??????? ?? ??????? ?????.
  2. ??? ???? ????? ???? ??????? ??????:
         
    A1: TestXLM
    A2: =ALERT("TestXLM works!")
    A3: =RETURN()
    						
    ??? ??????? ???? ???? ???????.
  3. ??? ?????? A1 ?? ???? ?????.
  4. ?? ??????? ????? ? ??? ??? ??? ? ?? ???? ??? ?????.
  5. ???? ?? ???? ????????? ??????? ?? ???? ?????? ????? ???:

      • ????? ???? ??????? ?? ?????? ??? ??? TestXLM.
      • ????? ?????? ???? ??? ?????? = ?????1! $ A $ 1.
      • ??? ????? ?????? ??????? ??? ?????.


    ????? ???? ????????? ??? ??????? ?????, ???? ??? "?????" ????? ??? ???????.
  6. ?? ?????? ??????? 1 ? ???? ????????? ??????? ???????:
     Option Explicit
    
     'The TestVBSub subroutine displays a message box: it is the Visual
     'Basic equivalent of the TestXLM macro shown above.
    
     Sub TestVBSub()
         MsgBox "TestVBSub works!"             'Displays a message box.
     End Sub
    
     'The Test1 Sub procedure makes use of the Application.Run method with
     'hard-coded macro/subroutine names.
    
     Sub Test1()
         Application.Run "TestVBSub"
         Application.Run "TestXLM"
     End Sub
    
     'The Test2 Sub procedure makes use of the Application.Run method with
     'variable macro/Sub procedure names.
    
     Sub Test2()
         Dim SubToRun As String, MacroToRun As String
         SubToRun = "TestVBSub"
         MacroToRun = "TestXLM"
         Application.Run SubToRun
         Application.Run MacroToRun
     End Sub
    
     'The Test3 Sub procedure makes use of the
     'Application.ExecuteExcel4Macro
     'method with hard-coded macro/Sub procedure names.
    
     Sub Test3()
         'Note the extra quotation marks which are contained within the
         'RUN statements. These are required in order for the command to
         'evaluate properly.
         Application.ExecuteExcel4Macro "RUN(""TestVBSub"")"
         Application.ExecuteExcel4Macro "RUN(""TestXLM"")"
     End Sub
    
     'The Test4 Sub procedure makes use of the
     'Application.ExecuteExcel4Macro
     'method with variable macro/Sub procedure names.
    
     Sub Test4()
         Dim SubToRun As String, MacroToRun As String
         SubToRun = "TestVBSub"
         MacroToRun = "TestXLM"
         'Note the extra quotation marks which are contained within the
         'RUN statements. These are required in order for the command to
         'evaluate properly.
         Application.ExecuteExcel4Macro "RUN(""" & SubToRun & """)"
         Application.ExecuteExcel4Macro "RUN(""" & MacroToRun & """)"
     End Sub
    
     'The Test5 Sub procedure uses the Call method with hard-coded
     'Sub procedure names.
    
     Sub Test5()
         Call TestVBSub
     End Sub
    
     'The Test6 Sub procedure runs the TestVBSub subroutine because its
     'name is entered on a line by itself.
    
     Sub Test6()
         TestVBSub
     End Sub
    
    					
??? ????? Test1 ?? Test2 Test3 ?? Test4 ????? ??????? ????? ?? ????? "TestVBSub ????!" ? "TestXLM ????!" ??? ????? Test5 ?? Test6 ????? ???? ??????? ???? ?? ??????? "TestVBSub ????!"

???????

???? ???????: 213837 - ????? ??? ??????: 05/????/1428 - ??????: 3.7
????? ???
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 2002 Standard Edition
????? ??????: 
kbmt kbmacro kbdtacode kbhowto kbprogramming KB213837 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????213837

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