home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Programmer'…arterly (Limited Edition)
/
Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso
/
code
/
ch26code
/
listings
/
26lst01.txt
next >
Wrap
Text File
|
1995-08-01
|
2KB
|
69 lines
Option Explicit
Dim Excel As Object
Sub RecordedForVB4()
'********************************************************
' This code was unmodified from Excel's recorder,
' except the With Excel...End With statement. This
' statement is required because VB needs to know which
' object it should reference.
'********************************************************
With Excel
.Workbooks.Add
.Range("A2").Select
.ActiveCell.FormulaR1C1 = "North"
.Range("A3").Select
.ActiveCell.FormulaR1C1 = "South"
.Range("A4").Select
.ActiveCell.FormulaR1C1 = "East"
.Range("A5").Select
.ActiveCell.FormulaR1C1 = "West"
.Range("B1").Select
.ActiveCell.FormulaR1C1 = "Spring"
.Range("C1").Select
.ActiveCell.FormulaR1C1 = "Summer"
.Range("D1").Select
.ActiveCell.FormulaR1C1 = "Fall"
.Range("E1").Select
.ActiveCell.FormulaR1C1 = "Winter"
.Range("B2").Select
.ActiveCell.FormulaR1C1 = "100"
.Range("C2").Select
.ActiveCell.FormulaR1C1 = "125"
.Range("D2").Select
.ActiveCell.FormulaR1C1 = "108"
.Range("E2").Select
.ActiveCell.FormulaR1C1 = "97"
.Range("E3").Select
.ActiveCell.FormulaR1C1 = "118"
.Range("D3").Select
.ActiveCell.FormulaR1C1 = "110"
.Range("C3").Select
.ActiveCell.FormulaR1C1 = "109"
.Range("B3").Select
.ActiveCell.FormulaR1C1 = "110"
.Range("B2:E3").Select
.Selection.AutoFill Destination:=.Range("B2:E5"), _
Type:=xlFillDefault
.Range("B2:E5").Select
.Range("A1:E5").Select
.Calculate
.Charts.Add
End With
End Sub
Private Sub Command1_Click()
'********************************************************
' Create the object, make Excel visible, run the macro,
' then free the object.
'********************************************************
Set Excel = CreateObject("Excel.Application")
Excel.Visible = True
RecordedForVB4
Excel.ActiveWorkbook.Saved = True 'Ignore changes
MsgBox "Macro Complete!"
Excel.Quit
Set Excel = Nothing
Unload Me
End Sub