View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
gmorris[_9_] gmorris[_9_] is offline
external usenet poster
 
Posts: 1
Default Copy a sheet from one workbook to another


cupboy;324242 Wrote:
Here's my code which does nothing. Generates no error, but doesn't copy
the
sheet into the workbook. It does successfully rename the "Operations"
sheet,
but is supposed to copy a sheet into the workbook in front of that
one.

private void CopyTab(excel.Worksheet ws, excel.Workbook wb)
{
try
{
foreach (excel.Worksheet w in wb.Sheets)
{
if (w.Name.IndexOf("Operations") -1)
{
w.Copy(ws, Type.Missing); // copy ws into wb workbook
// gets no error, but doesn't do anything else either!
w.Name = "Operations (updated)";
break;
}
} // end foreach
}

I can only assume that this is from a Windows Script file or something,
it looks like JavaScript or C. This forum is for VBA, so you may not get
a lot of help with it here. If you want to do this through Excel's VBA
it will be a lot easier!


--
gmorris
------------------------------------------------------------------------
gmorris's Profile: http://www.thecodecage.com/forumz/member.php?userid=245
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=90608