accessman2
Registered User.
- Local time
- Today, 14:12
- Joined
- Sep 15, 2005
- Messages
- 335
Hi,
I placed many Excel files in the share folder. And then, I create a MS Access form, and one button, the button will copy the worksheets of one Excel file, and then create the new workbook, and paste it over there.
Dim obj As Object
Dim objXL As Object
Dim objActiveWrb As Object
Set obj = GetObject("c:\Test.xls")
obj.Worksheets(1).Copy
Set objXL = CreateObject("Excel.Application")
objXL.Application.Workbooks.Add
Set objActiveWkb = objXL.Application.ActiveWorkBook
With objActiveWkb
.Worksheets(1).Cells(1, 1) = obj.Worksheets(1).Paste
End With
objXL.Visible = True
What's wrong with it?
I placed many Excel files in the share folder. And then, I create a MS Access form, and one button, the button will copy the worksheets of one Excel file, and then create the new workbook, and paste it over there.
Dim obj As Object
Dim objXL As Object
Dim objActiveWrb As Object
Set obj = GetObject("c:\Test.xls")
obj.Worksheets(1).Copy
Set objXL = CreateObject("Excel.Application")
objXL.Application.Workbooks.Add
Set objActiveWkb = objXL.Application.ActiveWorkBook
With objActiveWkb
.Worksheets(1).Cells(1, 1) = obj.Worksheets(1).Paste
End With
objXL.Visible = True
What's wrong with it?