|
-
Oct 3rd, 2003, 07:09 AM
#1
Thread Starter
Junior Member
VB6 and Excel
Hi all,
I would like my VB program to open two Excel workbooks and copy the sheets from workbook1 to workbook2. Is there a way to do this?
I tried to the Copy method, and Save, Add. But they do not work.
All seem to point to working with one workbook only.
I apologise if this query has already been answered, but I could not find any threads that could help.
Many thanks for your time.
-
Oct 4th, 2003, 10:31 PM
#2
-
Oct 4th, 2003, 11:16 PM
#3
Fanatic Member
The Copy method should work.
VB Code:
Sub CopyExcelSheets()
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
With objExcel
' Copy sheets from 2nd book to 1st book.
.Workbooks.Open filename:="C:\My Documents\A1.xls"
.Workbooks.Open filename:="C:\aaaWork\Queues1.xls"
.Workbooks(2).Sheets.Copy After:=.Workbooks(1).Sheets(.Workbooks(1).Sheets.Count)
.Workbooks(1).Save
.Quit
End With
Set objExcel = Nothing
End Sub
-
Oct 7th, 2003, 06:06 AM
#4
Thread Starter
Junior Member
VB6 and Excel
Many Thanks to both of you for your help.
Will try both.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|