home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / comexcel / comexcel.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-04-03  |  1.5 KB  |  48 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2076
  5.    ClientLeft      =   6432
  6.    ClientTop       =   4620
  7.    ClientWidth     =   2580
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   2076
  10.    ScaleWidth      =   2580
  11.    Begin VB.CommandButton Command1 
  12.       Caption         =   "GO!!"
  13.       Height          =   495
  14.       Left            =   720
  15.       TabIndex        =   0
  16.       Top             =   840
  17.       Width           =   1215
  18.    End
  19. Attribute VB_Name = "Form1"
  20. Attribute VB_GlobalNameSpace = False
  21. Attribute VB_Creatable = False
  22. Attribute VB_PredeclaredId = True
  23. Attribute VB_Exposed = False
  24. Option Explicit
  25. Private Sub Command1_Click()
  26.     Dim x As Excel.Application
  27.     Set x = CreateObject("excel.application")
  28.     x.Visible = True
  29.     Dim Book As Excel.Workbook
  30.     Set Book = x.Workbooks.Add(xlWorksheet)
  31.     x.ActiveSheet.Name = "Market Share Percentages!"
  32.         
  33.     x.ActiveSheet.Range("A2").Value = "Company A"
  34.     x.ActiveSheet.Range("B2").Value = "Company B"
  35.     x.ActiveSheet.Range("C2").Value = "Company C"
  36.     x.ActiveSheet.Range("D2").Value = "Company D"
  37.     x.ActiveSheet.Range("A3").Value = 75
  38.     x.ActiveSheet.Range("B3").Value = 14
  39.     x.ActiveSheet.Range("C3").Value = 7
  40.     x.ActiveSheet.Range("D3").Value = 4
  41.     Dim Range As Excel.Range
  42.     Set Range = x.ActiveSheet.Range("A2:D3")
  43.     Book.Charts.Add.ChartWizard Range, xl3DPie, 7, xlRows, 1, 0, 2, "Market Share"
  44.     Sleep 6000
  45.     Book.Saved = True
  46.     x.Quit
  47. End Sub
  48.