|
-
Jan 16th, 2006, 06:19 PM
#1
Thread Starter
Fanatic Member
Sheets Failing to Copy
I am running into a problem when trying to copy multiplesheets in a row in excel. The copy works if its only 1 or 2 sheets but anything over 2 copies in a row it fails, and I dont get an error.
I am using this code...
VB Code:
Set oSheet = oBook.Worksheets(oBook.Sheets(oBook.Sheets.Count).Name)
lngSheetCount = oBook.Sheets.Count
'Copy inital last sheet into new sheet
oExcel.ActiveWorkbook.Sheets(lngSheetCount).Copy _
After:=oExcel.ActiveWorkbook.Sheets(lngSheetCount)
Set oSheet = oExcel.ActiveSheet
'Rename the worksheet
oSheet.Name = Firms.Item(clc)
I was wondering if anyone else had run into this issue, I have tried placing DoEvents in some places to try to pass control back to windows so it could finish the copy but it doesnt seem to work.
-
Jan 17th, 2006, 01:00 PM
#2
Re: Sheets Failing to Copy
Moved to Office Development
-
Jan 17th, 2006, 01:01 PM
#3
Re: Sheets Failing to Copy
It could be because of the use of the "ActiveWorkbook" object instead of the Workbooks collection.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 17th, 2006, 01:44 PM
#4
Frenzied Member
Re: Sheets Failing to Copy
I think this may be what you want to do (???):
Code:
Sheets(Array("Sheet5", "Sheet3", "Sheet1")).Copy
I can't figure out how your code is trying to work with multiple sheets (???).
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
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
|