+ Reply to Thread
Results 1 to 8 of 8

ThisWorkbook.Name without extension name

Hybrid View

  1. #1
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    ThisWorkbook.Name without extension name

    Hi friends,
    I have an excel file named Budget.

    After running following macro, there is a "Budget" in the A1 cell.
    Sub Macro1()
    Range("A1").Value = ThisWorkbook.Name
    End Sub
    Then I change my folder settings that, yes show file extension name.

    After running following macro, there is a "Budget.xlsm" in the A1 cell.
    Sub Macro1()
    Range("A1").Value = ThisWorkbook.Name
    End Sub
    I dont want to see Budget.xlsm in the A1 cell.
    I want to see Budget in the A1 cell.

    Any advice ?
    Thanks in advance.
    Last edited by HerryMarkowitz; 12-13-2013 at 09:27 AM.
    Sub DontForgetThese()
         If Your thread includes any code Then Please use code tags...
         If Your thread has been solved Then Please mark as solved...
         If Anybody has helped to you Then Please add reputation...
    End Sub

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: ThisWorkbook.Name without extension name

    Use
    ThisWorkbook.Title
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: ThisWorkbook.Name without extension name

    You may use:
    Sub Macro1()
    Range("A1").Value = Left$(ThisWorkbook.Name, instrrev(ThisWorkbook.Name, ".") - 1)
    End Sub

  4. #4
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: ThisWorkbook.Name without extension name

    Code sent by OllyXLS is not working.
    Code sent by Izandol is working.
    Thank both of you.

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: ThisWorkbook.Name without extension name

    Quote Originally Posted by HerryMarkowitz View Post
    Code sent by OllyXLS is not working.
    You did replace just the relevant section of your macro, didn't you?

    Sub Macro1()
    Range("A1").Value = ThisWorkbook.Title
    End Sub
    As that should work...

  6. #6
    Forum Contributor HerryMarkowitz's Avatar
    Join Date
    09-10-2012
    Location
    Europe
    MS-Off Ver
    Office 2021 - Win10
    Posts
    1,014

    Re: ThisWorkbook.Name without extension name

    Yes I run code and no result...
    Last edited by HerryMarkowitz; 12-15-2013 at 02:25 PM.

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: ThisWorkbook.Name without extension name

    My apologies - I was wrong.

    The workbook I tested it on just happened to have an identical filename and document title... Good old SharePoint.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: ThisWorkbook.Name without extension name

    Olly

    Title won't work with a workbook that hasn't been saved and it won't necessarily return the workbook name, you can set the title of a workbook to whatever you want.
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ThisWorkbook Help
    By OcMac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2012, 05:36 PM
  2. [SOLVED] Set Wb = ThisWorkbook
    By ATLGator in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-01-2012, 02:10 PM
  3. Replies: 1
    Last Post: 05-28-2005, 12:52 PM
  4. [SOLVED] Help with ThisWorkbook
    By David in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-27-2005, 07:05 PM
  5. [SOLVED] RE: Help with ThisWorkbook
    By K Dales in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-27-2005, 05:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1