????? ??? ?????? Excel ?? Visual Basic

?????? ????????? ?????? ?????????
???? ???????: 147650 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ??? ????? ??????? ?????? ? ?????? ??? ?????? Microsoft Excel ???????:

  • ???????? longhand ? ?????????
  • ???????? ??? ??????
  • ??????? ?????? ????? ?? ????? Microsoft Excel ??????? 5.0 ?????? ?????? ??? ?? ???? Microsoft Excel

??????? ????

???? ?? ???? ?? Microsoft Excel ??????? 5.0 ???? ?? ?? ??????? ?????? ??????? ?? ????????. ???????? ??? ??? ???????? ??? ???????? ??? ???? ??????? ?????? ??? ???????. ?? ???? ??????? ?????? ??? ?? ???? ???????. ?? ????? ?? ??????? ?????? ?????? ????? ???? ??? ????????? ???????. ??? ???? ??????:
   ' Close the application
   [Object].Application.Quit
				
??????? [????] ?? ?? ????? ???? ??? ?? ???? "???? Microsoft Excel ?????????", ???? ???? ?????? ?? ?????? ??????:
   ' MyObject represents [Object] and OLE1 represents an OLE control
   ' that contains an Microsoft Excel Worksheet object.
   MyObject = OLE1.Object
   Set MyObject = CreateObject("Excel.Sheet")
   Set MyObject = GetObject("C:\EXCEL\EXAMPLES\SAMPLES.XLS")
				
???? "???????" ????? ??? ?????? ???? ?????. ??? ???? ??????? ????? ??????? ????????? ???????? ??????? ??????? ??? ?????? ???????? ???? ?? ??????? ?????? ?? Microsoft Excel:
   [Object].Application.Workbooks
				
??? ???? ??????? ???? ???? ?? ???????? ??????? ??????? ????. ??? ???? ??????? ??????? ??? ??? ????:
    [Object].Application.Workbooks.Item(1)
				
??? ????? ?????? ?????:
   [Object].Application.Workbooks.Item(1).Close
				

?????? ??? ?????? ??????? ???? Longhand ?? ????? ????????

?? ???? ????? ??? ?????? ?? ????? ?????, ?? ???? ??? ????? ??? ?????? ?? ??????? ?????. (???? ????? Microsoft Excel ?????????? ??????? ?????? ??? ???????? ?????? ??? ??????? ?????? ???? Microsoft Excel.) ?? ????????? ????????? ?? ????? ??? ???? ????? ?? ????:
   ' Following refers to cell A1 on Sheet1 in the first workbook.
   ' Enter the following two lines as one, single line:
   [Object].Application.Workbooks.Item(1).
      WorkSheets.Item("Sheet1").Cells.Item(1,1)
				
???? ?? ???? ??? ?????? ?????? ????????; ??? ???? ????? ????????. ???? ??? ???? ??????? "??????" (.) ???????? ????? ?????? ???????.

?? ???????

????? ???? ???????? ??????? ?????????? ????????. ?????? ??????? ????????? ?? ????? ????. ???? ???????? ?? ??????? ??? ????? ????????. ?? ????? ??? ???????? ?????? ???????. ??? ???? ??????? ????? ????? ?????? ???:
   [Object].Application.Workbooks(1).WorkSheets("Sheet1").Cells(1,1)
				

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

????? ??????? ??? ?????? ?????? ????? ??????. ??? ??? ???? ????? ???? ?? ????????? ???????? ???? ?? ???????? ??????1 ??? ???? ??????? ???? ?????? ?? ???? ?????. ???? ??? ????? ???? ???? ??? ???? ??????? ???. ????? ??? ??????. ?????? ????? ????? ????? ??? ??????:
   Dim Sheet1 as Object
   ' Alias Sheet1 to represent [Object]...WorkSheets("Sheet1")
   Set Sheet1 = [Object].Application.Workbooks(1).WorkSheets("Sheet1")
   ' Now just use the variable Sheet1 to refer to Sheet1.
   Sheet1.Cells(1,1).Value = "Title"
   Sheet1.Cells(1,2).Value = "ID"
   Sheet1.Cells(1,3).Value = "Cost"
   Sheet1.Cells(2,1).Value = "Phone"
   Sheet1.Cells(2,2).Value = 123413423
   Sheet1.Cells(2,3).Value = 89.95
				

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

???? ?????? ????? ?? ????? ???????? ???? ??????? ?????? ?????? ??? ????. ????? ????? ?????? ??? ???? ??????? ???????? ????? ????? ?????? ????? ???? ?? ??????? ?????? ????. ??? ????? ???? ??????? ???????? ?? ??? ??????? ?? [????]. ????? [????] ???? Microsoft Excel ???? ???? ??? ???????? ????? ?????. ??? ????? ?? ?????? [????].

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

  • Excel.Application
  • Excel.Sheet
  • Excel.Chart
?? ???? ??? ?????? Excel.Application.5. ???? Excel.Application ?????? ??? ???? ????? ?? Microsoft Excel. Excel.Application.5 ???? ??? ??? Microsoft Excel ??????? 5.0.

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

??????: oleExcel ?? ???? ???? OLE ???? ????? ??? ???? Excel.Sheet.
   ' Declare object references:
   Dim Xlapp As object
   Dim XLWkb As object
   Dim XLWks As object
   Dim XLWksNew As object

   oleExcel.Action = 7   ' Activate OLE Object

   Set XLWks = oleExcel.Object   ' Alias Worksheet object
   Set XLWkb = XLWks.Parent      ' Alias WorkBook object
   Set Xlapp = XLWks.Application ' Alias Application object

   ' Add a new worksheet to the Workbook and name it:
   Set XLWksNew = XLWkb.Worksheets.add  ' Assign alias to new Worksheet
   XLWksNew.Name = "VB4 OLE Automation" & XLWkb.Worksheets.count

   ' Make the 3rd Worksheet of the Workbook active:
   XLWkb.Worksheets(3).Activate

   ' Display the dialog for InsertPicture:
   Xlapp.dialogs(342).[Show]  ' xlDialogInsertPicture = 342
				

?????

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

???????

???? ???????: 147650 - ????? ??? ??????: 18/?????/1427 - ??????: 2.3
????? ???
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic 4.0 16-bit Enterprise Edition
  • Microsoft Excel 5.0 Standard Edition
????? ??????: 
kbmt kb16bitonly kbhowto kbprogramming KB147650 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????147650
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

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

 

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