View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NewToVB NewToVB is offline
external usenet poster
 
Posts: 48
Default Changing Sheet Names

I'm having trouble changing the names of my worksheets in my new workbook,
can someone help? Here is the code that I have. I'm using Visual Studio
2005, Excel 2007 and VB, here is some of the code I have. Thanks!

Dim LCV = New Excel._ExcelApplication
LCV = CreateObject("Excel.Application")
Dim oBook As Excel.Workbook
Dim oBooks As Excel.Workbooks
Dim oSheets As Excel.Sheets
Dim oSheet1 As Excel.Worksheet

oBooks = LCV.Workbooks
oBook = oBooks.Add()
oSheets = oBook.Worksheets <----I get an error saying COM unhandled
oSheet1 = oSheets.Add
oSheet1.Name = "Portfolio"


I know it already has 3 sheets when you create a new workbook, but how do
you change those names?