We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

VBA Calling WorkbookName minus the .xls

troyhalsey
troyhalsey asked
on
Medium Priority
236 Views
Last Modified: 2012-06-21
How do I grab a workbook name without the file extension?

This is what I get with ThisWorkBook.Name = PM.xls

What I want is just = PM

Suggestions?

Troy
Comment
Watch Question

Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
left(ThisWorkBook.Name, len(ThisWorkBook.Name)-4)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT
Top Expert 2010

Commented:
Hi Troy,

SomeVar = Left(ThisWorkbook.Name, InStrRev(ThisWorkbook.Name, ".xls", -1, vbCompareText) - 1)

Regards,

Patrick

Commented:
Left(ThisWorkBook.Name,Instrrev(ThisWorkBook.Name,".") -1)

Author

Commented:
Thanks!!!
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
Let me clarify that the other 2 suggestions are more generic in the sense that excel can open documents that are not necessarily .xls but can have any other extensions...
CERTIFIED EXPERT
Top Expert 2010

Commented:
> Let me clarify that the other 2 suggestions are more generic

Well, really Vinny's was the only generic solution--my suggestion was still looking for a XLS extension :)

Patrick
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.