I am trying to create an Excel workbook which would package a number of other Excel files selected from a listbox as worksheets, from within Access. I have been successful inserting the workbooks as objects from a file (OLEObjects.Add) but this creates a worksheet inside a worksheet. If I use the open command it will open the spreadsheet as a separate workbook. What options are there besides OLEObjects.Add to create a worksheet from a file?
Set oExcel = GetObject("Excel.Application"
If Err.Number <> 0 Then
Set oExcel = CreateObject("Excel.Application"
End If
oExcel.Visible = True
oExcel.Workbooks.Add
Set oWb = oExcel.ActiveWorkbook
For i = 0 To Me.lstFileList.ListCount - 1
If Me.lstFileList.Selected(i) Then
Set oWs = New Worksheet
Set oWs = oWb.Worksheets.Add()
oWb.Sheets(oWs.Name).Select
oWs.Name = Me.lstFileList.Column(0, i)
oExcel.ActiveSheet.OLEObjects.Add(Filename:=GetOutboxDir _
& Me.lstFileList.Column(0, i), _
Link:=False, DisplayAsIcon:= _
False).Select
End If
Next i ----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------
Set oExcel = GetObject("Excel.Application"
If Err.Number <> 0 Then
Set oExcel = CreateObject("Excel.Application"
End If
oExcel.Visible = True
oExcel.Workbooks.Add
Set oWb = oExcel.ActiveWorkbook
For i = 0 To Me.lstFileList.ListCount - 1
If Me.lstFileList.Selected(i) Then
Set oWs = New Worksheet
Set oWs = oWb.Worksheets.Add()
oWb.Sheets(oWs.Name).Select
oWs.Name = Me.lstFileList.Column(0, i)
oExcel.ActiveSheet.OLEObjects.Add(Filename:=GetOutboxDir _
& Me.lstFileList.Column(0, i), _
Link:=False, DisplayAsIcon:= _
False).Select
End If
Next i ----------------------
scking@arinc.com
Life is filled with lessons.
We are responsible for the
results of the quizzes.
-----------------------