Results 1 to 8 of 8

Thread: [RESOLVED] Renaming a Workbook

  1. #1

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Resolved [RESOLVED] Renaming a Workbook

    I have created an EXCEL appliction:
    VB Code:
    1. Set ExcelApp = CreateObject("Excel.Application")
    2. 'ExcelApp.Visible = False
    3. Set ExcelBook = ExcelApp.workbooks.Add
    And I realy want to rename the book to more than BOOK1

    Is it possible?
    I've had enough with sainity!
    What's the use of it anyway?

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Renaming a Workbook

    Do you want to rename it when you save?
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Renaming a Workbook

    the best way to rename a workbook is when you save it

    VB Code:
    1. ExcelBook.SaveAs Filename:="c:\WhatEverYouWant.xls"

  4. #4

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Renaming a Workbook

    I want it to have a name before saving. If it's possible, then name should be changed when the workbook has been created.
    Thus, the end user will not have to wonder for a filename.
    I've had enough with sainity!
    What's the use of it anyway?

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Renaming a Workbook

    Create a template workbook named as you want and refer to it when you open it via code. It will append a 1 or whatever count of that workbook are open. Just like Word does with its Document1 etc.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Renaming a Workbook

    Can I create the template in runtime without saving it?
    I've had enough with sainity!
    What's the use of it anyway?

  7. #7
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Renaming a Workbook

    Nope.

    You can just create a blank new document and then save it to the disk as the filename you want and then reopen it for displaying to the user. Its about the only way as the .Name property of the document is read only.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  8. #8

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Renaming a Workbook

    10X
    I've had enough with sainity!
    What's the use of it anyway?

Posting Permissions

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



Click Here to Expand Forum to Full Width