????? ????? ????? Excel w/OLE ??????? ?? Visual Basic

?????? ????????? ?????? ?????????
???? ???????: 142387 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

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

??????? ????

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

  1. ??? ????? ???? ?? Visual Basic. ??? ????? Form1 ???? ???????.
  2. ????? ?? ??? (Command1) ??? Form1.
  3. ?? ?????? ????????? ???????? ??????? ??? ????? ????? Command1_Click:
      Private Sub Command1_Click()
       
        Dim oXL As Object        ' Excel application
        Dim oBook As Object      ' Excel workbook
        Dim oSheet As Object     ' Excel Worksheet
        Dim oChart As Object     ' Excel Chart
        
        Dim iRow As Integer      ' Index variable for the current Row
        Dim iCol As Integer      ' Index variable for the current Row
        
        Const cNumCols = 10      ' Number of points in each Series
        Const cNumRows = 2       ' Number of Series
    
        
        ReDim aTemp(1 To cNumRows, 1 To cNumCols)
        
        'Start Excel and create a new workbook
        Set oXL = CreateObject("Excel.application")
        Set oBook = oXL.Workbooks.Add
        Set oSheet = oBook.Worksheets.Item(1)
        
        ' Insert Random data into Cells for the two Series:
        Randomize Now()
        For iRow = 1 To cNumRows
           For iCol = 1 To cNumCols
              aTemp(iRow, iCol) = Int(Rnd * 50) + 1
           Next iCol
        Next iRow
        oSheet.Range("A1").Resize(cNumRows, cNumCols).Value = aTemp
        
        'Add a chart object to the first worksheet
        Set oChart = oSheet.ChartObjects.Add(50, 40, 300, 200).Chart
        oChart.SetSourceData Source:=oSheet.Range("A1").Resize(cNumRows, cNumCols)
    
        ' Make Excel Visible:
        oXL.Visible = True
    
        oXL.UserControl = True
            
    End Sub
    					
  4. ???? ??????? F5 ?????? ???????? ?? ???? ??? ?? ?????.
???? Microsoft Excel ???????: ? ??? ????? ???? ????. ??? ????? ?????? ??????? ??? ??????? A1:J2 ????????? ????? ??? ???? ????? ??????. ?????? ??????? ?????? ?????? ??????? ???? ???????? ????? ??.

???????

???? ???????: 142387 - ????? ??? ??????: 12/????? ??????/1425 - ??????: 4.3
????? ???
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 2000 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Visual Basic 5.0 Enterprise Edition
????? ??????: 
kbmt kbhowto kbprogramming KB142387 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????142387

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

 

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