home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 1997 / CT_SW_97.ISO / pc / software / entwickl / win95 / pw32i306.exe / eg / excel2.pl < prev    next >
Text File  |  1996-06-27  |  2KB  |  82 lines

  1. #Sub Command1_Click ()
  2. #
  3. #    Dim ExcelApp As Object
  4. #    Dim ExcelChart As Object
  5. #    Dim CharTypeVal As Integer
  6. #    Dim i as Integer
  7. #
  8. #    '-4100 is the value for the Excel constant xl3DColumn. Visual
  9. #    'Basic does not understand Excel constants, so the value must be
  10. #    'used instead.
  11. #    ChartTypeVal = -4100
  12. #
  13. #    'Creates OLE object to Excel
  14. #    Set ExcelApp = CreateObject("excel.application")
  15. #
  16. #    'Sending VB Applications Edition commands to Excel via the new OLE
  17. #    'object to create a new workbook fill in numbers, create the chart, and
  18. #    'rotate the chart.
  19. #
  20. #    ExcelApp.Visible = True
  21. #    ExcelApp.Workbooks.Add
  22. #    ExcelApp.Range("a1").Value = 3
  23. #    ExcelApp.Range("a2").Value = 2
  24. #    ExcelApp.Range("a3").Value = 1
  25. #    ExcelApp.Range("a1:a3").Select
  26. #    Set ExcelChart = ExcelApp.Charts.Add()
  27. #    ExcelChart.Type = ChartTypeVal
  28. #    For i = 30 To 180 Step 10
  29. #        ExcelChart.Rotation = i
  30. #    Next
  31. #
  32. #    ExcelApp.ActiveWorkbook.Close (False)
  33. #    ExcelApp.Quit
  34. #    Set ExcelChart = Nothing
  35. #    Set ExcelApp = Nothing
  36. #    End
  37. #End Sub
  38. #To use this subroutine, create a form in Visual Basic and add a single
  39. #button to that form. Double-click the button and type the code shown above
  40. #in the procedure window. Close the procedure window, and choose Start from
  41. #the Run menu. To see the rotating chart, click on the button in your form.
  42. #
  43.  
  44. #set the include path.
  45. BEGIN {
  46.  
  47. @INC = qw( ..\lib ..\ext );
  48.  
  49. }
  50.  
  51. use OLE;
  52.  
  53.  
  54. #   -4100 is the value for the Excel constant xl3DColumn.
  55.  
  56. $ChartTypeVal = -4100;
  57.  
  58. #   Creates OLE object to Excel
  59. $ExcelApp = CreateObject OLE "excel.application" || die "Unable to create Excel Object: $!\n";
  60.  
  61. # Create and rotate the chart
  62.  
  63. $ExcelApp->{'Visible'} = 1;
  64. $ExcelApp->Workbooks->Add();
  65. $ExcelApp->Range("a1")->{'Value'} = 3;
  66. $ExcelApp->Range("a2")->{'Value'} = 2;
  67. $ExcelApp->Range("a3")->{'Value'} = 1;
  68. $ExcelApp->Range("a1:a3")->Select();
  69. $ExcelChart = $ExcelApp->Charts->Add();
  70. $ExcelChart->{'Type'} = $ChartTypeVal;
  71.  
  72. for($i=30;$i<180;$i+=10)
  73. {
  74.     $ExcelChart->{'Rotation'} = $i;
  75. }
  76.  
  77. # Done, bye
  78.  
  79. $ExcelApp->ActiveWorkbook->Close(0);
  80. $ExcelApp->Quit();
  81.  
  82.