Consulting

Results 1 to 1 of 1

Thread: create and hide an excel sheet from ppt

  1. #1

    create and hide an excel sheet from ppt

    All,

    I want to build some code, integration Powerpoint and Excel. One thing I want to do is to create a new sheet in (the active workbook in) Excel, and hide it (and leave the originally active sheet active). I've written the code below.

    I would expect a new sheet to be created and inserted at the end of the existing sheets, and being hidden. However, the sheet is created, but it's not hidden, and it's not at the end of the sheets (but at the position of the activesheet). Furthermore, the current_sheet is not activated/selected. Anyone any idea what's going wrong?

    To be complete: i'm using old-fashioned Office 2000. Nothing to do about that...

    Groet,

    Bart

    sub create_excel_sheet()
    dim ExcelObject as Excel.Application
    Dim settings_sheet As Excel.Worksheet
    dim current_sheet as Excel.Worksheet
    Set ExcelObject = GetObject(, XLAPPCLASS) 'Gets the active excel
    Set current_sheet = ExcelObject.ActiveSheet
    Set settings_sheet = ExcelObject.Sheets.Add (After:=ExcelObject.Worksheets.Count)
    settings_sheet.visible=false
    current_sheet.activate
    end sub
    Last edited by Aussiebear; 04-28-2023 at 08:03 PM. Reason: Adjusted the code tags

Posting Permissions

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