L
Lamont
Is it possible select a range of cells in an Excel spreadsheet under access
from a VB6 program?
The many permutations I have tried shown below fail.
Surely I should be able to Select a range of cells, because I have to do
this to sort the rows.
Thanks for kind assistance. Lamont
Private DataRange As Excel.Range
Private DataSheet As New Excel.Worksheet
Private MyWorkbook As New Excel.Workbook
Private Sub Command1_Click()
Dim strMyXLSBkSpec As String
Form1.Show
strMyXLSInSpec = "C:\DocData.xls" 'My spreadsheet
containing data about paper documents
Set MyWorkbook = GetObject(strMyXLSInSpec) 'This works to access my
Excel File
MyWorkbook.Activate 'this works
Set DataSheet = MyWorkbook.Sheets("DataSheet") 'this works
Set DataRange = DataSheet.UsedRange 'this works
Debug.Print DataRange.Rows.Count 'this works
DataSheet.Activate 'this works
'DataRange.Select 'Select method of range class failed.
'DataSheet.Range(1, 1).Select 'Method "Range" of object failed
'DataSheet.Cells(1, 1).Select 'Select method of range class failed.
'Set DataRange = Range(1, 1) 'Select method of range class failed.
'Cells.Select 'Select method of range class failed.
'DataSheet.Cells.Select 'Select method of range class failed.
'Set DataRange = Range(A1, A99) 'Select method of range class failed.
'Set DataRange = DataSheet.Range(A1, P99) 'Select method of range class
failed.
'Set DataRange = DataSheet.Range(1, 99) 'Select method of range class
failed.
End Sub
from a VB6 program?
The many permutations I have tried shown below fail.
Surely I should be able to Select a range of cells, because I have to do
this to sort the rows.
Thanks for kind assistance. Lamont
Private DataRange As Excel.Range
Private DataSheet As New Excel.Worksheet
Private MyWorkbook As New Excel.Workbook
Private Sub Command1_Click()
Dim strMyXLSBkSpec As String
Form1.Show
strMyXLSInSpec = "C:\DocData.xls" 'My spreadsheet
containing data about paper documents
Set MyWorkbook = GetObject(strMyXLSInSpec) 'This works to access my
Excel File
MyWorkbook.Activate 'this works
Set DataSheet = MyWorkbook.Sheets("DataSheet") 'this works
Set DataRange = DataSheet.UsedRange 'this works
Debug.Print DataRange.Rows.Count 'this works
DataSheet.Activate 'this works
'DataRange.Select 'Select method of range class failed.
'DataSheet.Range(1, 1).Select 'Method "Range" of object failed
'DataSheet.Cells(1, 1).Select 'Select method of range class failed.
'Set DataRange = Range(1, 1) 'Select method of range class failed.
'Cells.Select 'Select method of range class failed.
'DataSheet.Cells.Select 'Select method of range class failed.
'Set DataRange = Range(A1, A99) 'Select method of range class failed.
'Set DataRange = DataSheet.Range(A1, P99) 'Select method of range class
failed.
'Set DataRange = DataSheet.Range(1, 99) 'Select method of range class
failed.
End Sub