You can use the Excel Object Model to automate Excel from VB 6.
VB Code:
Option Explicit 'Add a reference to MS Excel xx.0 Object Library Private Sub Command1_Click() Dim oApp As Excel.Application Dim oWB As Excel.Workbook Set oApp = New Excel.Application Set oWB = oApp.Workbooks.Open("C:\Book1.xls") oWB.Sheets("Sheet1").Cells(1, 1) = "My Name" oWB.Save oWB.Sheets("Sheet1").PrintOut [From], [To], [Copies], [Preview], [ActivePrinter], [PrintToFile], [Collate], [PrToFileName] oWB.Close Set oWB = Nothing oApp.Quit Set oApp = Nothing End Sub





Reply With Quote