?
Solved

VBA Calling WorkbookName minus the .xls

Posted on 2006-03-30
6
Medium Priority
?
211 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
0
Comment
Question by:troyhalsey
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 16333541
left(ThisWorkBook.Name, len(ThisWorkBook.Name)-4)
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 16333543
Hi Troy,

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

Regards,

Patrick
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 16333550
Left(ThisWorkBook.Name,Instrrev(ThisWorkBook.Name,".") -1)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:troyhalsey
ID: 16333791
Thanks!!!
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16333814
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...
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 16333956
> 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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question