PDA

View Full Version : Save Excel using VBA



smile_please
04-21-2010, 11:34 PM
Hi All,

I have an Excel file (For Eg; I have C:\Test.xlsx), In this file i need to insert a new sheet and save it.

Im able to insert a new sheet and save it, but when i open manually, the sheets are hidden. I need to goto View-> Unhide to view the sheets..

Is there any script to add a new sheet and it should be able to view when i open the file.

The script i used is:

Set C_WorkBook = GetObject("C:\Test.xlsx")
Set C_WorkSheet = C_WorkBook.Worksheets.Add
C_WorkSheet.Name = "ABC"
C_WorkBook.save
C_WorkBook.close


Thanks in Advance,
Bala

Bob Phillips
04-22-2010, 12:46 AM
I don't see why it should be hidden, but ...



Set C_WorkBook = GetObject("C:\Test.xlsx")
Set C_WorkSheet = C_WorkBook.Worksheets.Add
C_WorkSheet.Name = "ABC"
C_WorkSheet.Visible = xlSheetVisible
C_WorkBook.Save
C_WorkBook.Close

smile_please
04-22-2010, 07:17 PM
Thanks for your reply..
But I used the above script, but still the sheet are hidden only..

lucas
04-22-2010, 08:41 PM
If you add a sheet manually, is it hidden?

mdmackillop
04-22-2010, 11:21 PM
Can you post your workbook to check for other code which may be causing this?

smile_please
04-26-2010, 06:32 PM
If i add manually ths sheet is not hidden...

Bob Phillips
04-27-2010, 12:17 AM
Without seeing the workbook, there is little we can offer I feel.