Consulting

Results 1 to 7 of 7

Thread: Save Excel using VBA

  1. #1

    Smile Save Excel using VBA

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I don't see why it should be hidden, but ...

    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks for your reply..
    But I used the above script, but still the sheet are hidden only..

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If you add a sheet manually, is it hidden?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post your workbook to check for other code which may be causing this?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    If i add manually ths sheet is not hidden...

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Without seeing the workbook, there is little we can offer I feel.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •