XL: Excel ?? ??????? ?? ????? ???? ?? ??? ???????? ??? ?? ??? ?? ??????

???? ?????? ???? ??????
???? ID: 177991 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ???? ?? Microsoft Excel ???????????? ?? ?????? ??????? ?? ????? ???? ?? ??? ??????? ??? ?? ??? ?? ??? ?????? ?? ????? ???? ??? ?? ?????? ?? ??? ?? ??? ???, ??? ?? ???? ??????? ??? ??? ??-???? ?????? ??????? ?? ???? ???

???? ???????

Microsoft ???????????? ?????? ?? ?????? ????? ??, ???? illustration ?????? ?? ?? expressed ?? ???????, ????? ???? ?? ???, ??????? ?????? ?? ?????? ??/?? ???? ????? ???????? ?? ??? ????????? ????? ???? ????? ????? ?? ???? ????? ?? ?? ?? demonstrated ?? ??? ???????????? ???? ?? ????? ?? ???????????? ?? ???? ???? ?? ??? ????? ??? ??????? ?? ?????? ???? Microsoft ?????? ????????? ?? ????? ????????? ?? ???????????? ?? ?????? ??? ?????? ?? ???? ???, ????? ?? ?? ???????? ?? ???????? ??????????????? ?? ???? ??????? ?????????? ?? ??? ???????????? ???? ?? ??? ??????? ???? ???????
??? ?? ???????????? ????? ????? ??, ?? ?? ???? ?? ?? Microsoft ?????????? ??????? ?? Microsoft ??????? ???? ?? ?????? ????? ???? ??????? ?? ???, ????? Microsoft ??? ???? ?? ????:

Microsoft ??????? - ?????????? ????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?? Microsoft Excel ?? ??????? ?? ????? ???? ?? ??? ??????? ??? ?? ??? ??, ?? ????? ?????? ????, Excel ?? ?? ??? ?? ??? ?? ???? ?? ??? ?? ???? ???? ?????????? ?????? ?? ??? ?? ???? ?????? ?? ??? ?? ???? ?? ??? ??? ??????? ?? ???? ??? ?????? ?? ????? ?? ??? ????? ??????? ?????? ??????
   Version of          Passing Array to     Passing Array to
   Microsoft Excel     Worksheet Range      Macro (Procedure)
   ----------------------------------------------------------

   5.0                        A                B,C

   7.0 (Excel 95)             D                E,C,H

   8.0 (Excel 97)             F                G,H

   9.0 (Excel 2000)           F                G,H

				

??????

A:

???? ??? ?????? ?? ?????? ?????? ??? ???? 6550 ??? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ??????? ??? ?? ?? ?? ?????:
?????? ?? ????
1005: ?????? ???? ?? ??? ??? ?? ??? ???? ??? ??????
?? ?? ?? ???? ??? ??? Excel ?? ??? Excel ?????????? ?????? ?? ????? ???? ??? ???? ??? ?????? ?? ?????? ?????? ??? 4095 ??? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ????? ??????? ???? ??:
'1004' ??-???? ??????:
????????? ???? ?? ???? ???? ?? ???? ?????????? ????
B:

???? ??? ?????? ?? ?????? ?????? ??? 4095 ??? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ????? ??????? ?? ???? ??:
'1004' ??-???? ??????:
????????? ???? ?? ???? ???? ?? ???? ?????
????? ???: ???? multidimensional ???? ?? ??? ?? ??? ??, ?? ?? ???? ??????? ?? ???? ?? ?????? ????? ??, ????? Excel ?????? ????? ?? ?????? ?? ??? ?????? ?? 4095 ?? ???? ???? ??????

C:

?? Excel ?????? ??? ???? ???????? defining, ?? ?????? ?? ????????? Variant ?? ?? ??? ???, ?? ?????? ??????? ?? ????? ???? ?? ?????? ???? ??? ????? ?????? ????? ??????? ????:
'1004' ??-???? ??????:
?????? ?? ???? ???? ????<macro name=""> </macro>
?????? ?? ???, Excel ??? ???? ?????? ?? ??? ?? AcceptArray suppose. ???? ???? ???? ?????? ?? ??? ????????? Excel ?????? ?? ?? ?????? ??:
   Public Sub AcceptArray(ByVal myarray As Variant)
      ' You can pass the parameter either ByVal or ByRef.
      ' To determine the number of elements in the array, use
      ' the UBound function.
   End Sub
				
% D:

???? ??? ?????? ?? ?????? ?????? ??? 5461 ??? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ??????? ??? ?? ?? ??????? ???? ??:
'1004' ??-???? ??????:
????????? ???? ?? ???? ???? ?? ???? ?????????? ????
- ?? -
'1005' ??-???? ??????:
?????? ???? ?? ??? ??? ?? ??? ???? ??? ??????
E:

???? ??? ?????? ?? ?????? ?????? ??? 5461 ??? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ????? ??????? ???? ??:
'1004' ??-???? ??????:
????????? ???? ?? ???? ???? ?? ???? ?????
F:

?????? ?????? ?? Excel ?????? ???? ??? ?????? ?? ?????? ?????? ?? ????? ?????????? ?????? ???? (65536 ????????? X 256 ???????)? ???????, ?? Excel ?? ??? ?? ???? ??? ?? ???? ??? ?????? ?? ?????? ?????? ?? ????? ?? Excel ?????????? ?????? ?? 5461? ??? ?? ?? ???? ?? ???? ??, ?? ???? ????? ?????? ????? ??????? ???? ??:
'13' ??-???? ??????:
?????? ?????
G:

???? ??? ?????? ?? ?????? ?????? ?? ???? ?????? ?????? ?? ????? ??? ??? ??, ???? ??? ???? ???????? ?? Excel ??? ?????? ??? ?? Variant ?? ?? ??? ??? ????????? ???? ?? ???? ???????, ??? ?? ???? ?? ??? ByVal, ???? ?????? ????????? ???????? ?? ??? ??? ?? ???? ??? ???? C ?????? ??? ?????? ??? Variant ?? ?? ??? ???? ?? ?? ??-???? ?????? 13, "?????? ????? ??" ??????, ??????? ?????? ??? ?? ?? ?? Variant ?? ??? ??? ?? ???? ????????? ???

H:

?? ???? ??? ?? ???-??-????????? ??????? ?? ??? ?? ???? ByRef ?? ??? ??, ????? ???? Excel, ?? ???? marshalling ?? ??? ??????? ?? ??? ???????? (?? ???????) ?? ????? ??????? ?? ??? ??????????? ??? ?????? ???? ???? ?? ?? ?? ?? ??? ???? ?? ?? ???? Excel ByRef ?? ????? ???? ???, ???? ?? ?? ????????? ?? ???? ???? ?? Excel ?? ??? ?????? Excel ??? ????????? ???? ??, ?? ??? ???? ?? ?? ????????? ??????? ?? ???? ??? ??? ?????? ?? ByRef ?? ???-??-????????? ????? ?? ????? ???? ??? ???? ?? ??? ?? ??? ?? ?? ??? ?????? ???? ??, ?? ???? ?? ???? ???? ??? ?? ????? ???, ?? ?? ???? ByRef ?? ????? ?? ???? ???-????????? ??????? ????? (?? ????????-???? ????????? (DLL)) ?? ???? ???, ?? ?? ???? ???? ?? ??????? ??? marshalling ?? ??? ??? ????? ?? ????? ??? ???? ?????? ??? ??????? ?? ??? ???? ?? ???? ?? ??????? ????? ??????? ?? ??? ??? ?? ??? ????? ??? ????? ???

Excel ???? ?? ???-??-????????? ????? ?? ??? marshalling ?? ???? ???? ByRef ?? ???? ByVal ??? ???? ?? ??? ???? ???? ??? ?? ???, ???? ?? ????????? ?? ??? Excel ?? ??? ?? ?? Excel ????? ?? ??????? ?? ??? ???? ?? ??? ???? ??? ???? ???? ByVal Excel ?? ???? ?????? ?? ???, ?? ??? ???? ?????? ????????? ???????? Excel ?????? ??? Variant ?? ?? ??? ???? ?? ?????? ?? ??? ?? ???? ??? ???? C ?????? ??????

????? Visual Basic ????????????

????? sample Microsoft Visual Basic ????????? ?? ?? ??? ???????????? ?????? ??????? Excel ?? ??? ???? ?? ??? ???? ????? ???? ?? ???????????? ?? ???? ?????????? ?? ?????? ?? ?????? ?? ???? ?????????? ?????? ?? ??? ???? ???? ??? ?? ??? ?? ?????? ????????? ???? ?? ??? ???? ??????? ????? ????????? ?? ???? Excel ?????? ?? ??? ???? ???? ?? ??? ???? ?? ??? ???? ?????? ???

????? declarations ???????? ?????? ?? ??? ????? ???? ???? ??:
Option Explicit
???????? ?? ??? ??? ???? xlApp
???????? ?? ??? ??? ???? xlBook
???????? ?? ??? ??? ???? xlSheet
???? ?????????? ?????? ?? ??? ??? 1-Dimensional ???? ??? ?? ??? ??:
   Public Sub OneDimension()
      Const size = 5461
      Dim myarray(1 To size) As Integer
      Set xlApp = CreateObject("Excel.Application")
      xlApp.Visible = True
      Set xlBook = xlApp.Workbooks.Add
      Set xlSheet = xlBook.Worksheets("Sheet1")
      xlSheet.Cells(1, 1).Resize(size, 1).Value = _
         xlApp.Application.Transpose(myarray)
   End Sub
				
Passing a 2-Dimensional Array to a Worksheet Range:
   Public Sub TwoDimension()
      Const size = 2730
      Dim myarray(1 To size, 1 To 2) As Integer
      ' Number of elements = 2730 * 2 = 5460.
      Set xlApp = CreateObject("Excel.Application")
      xlApp.Visible = True
      Set xlBook = xlApp.Workbooks.Add
      Set xlSheet = xlBook.Worksheets("Sheet1")
      xlSheet.Cells(1, 1).Resize(size, 2).Value = myarray
   End Sub
				
Passing an Array as an Argument to an Excel Macro:
   Public Sub RunExcelMacro()
      Const size = 5461
      Dim myarray(1 To size) As Integer
      Set xlApp = CreateObject("Excel.Application")
      xlApp.Visible = True
      Set xlBook = xlApp.Workbooks.Open("C:\MyBook.xls")
      xlApp.Run "AcceptArray", myarray
   End Sub
				
The AcceptArray procedure within a module inside C:\MyBook.xls resembles the following:
   Option Explicit

   Public Sub AcceptArray(ByVal myarray As Variant)
      MsgBox "Size of first dimension: " & UBound(myarray, 1)
   End Sub
				

??????

For more information about arrays and Excel, please see the following articles in the Microsoft Knowledge Base:
166342XL97: Maximum Array Size in Microsoft Excel 97

153307HOWTO: Call Microsoft Excel Macros that Take Parameters

153090How To Pass a Visual Basic Array to an Excel Worksheet
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
163435VBA: Programming Resources for Visual Basic for Applications

???

???? ID: 177991 - ????? ???????: 18 ??????? 2011 - ??????: 6.0
???? ???? ???? ??:
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
  • Microsoft Office 2000 Developer Edition
??????: 
kbautomation kbinfo kbmt KB177991 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:177991

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

 

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