Adding only workbook name to message box

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Adding only workbook name to message box

Post by ABabeNChrist »

I use this type of message box that will add active workbook name alongside message.

Code: Select all

MsgBox "Your new report named " & ActiveWorkbook.Name & " is ready."
At the present moment next to the workbook name it also put the file extension type.
So it might look something like this
Your new report named John Doe.xlsm is ready
How can I remove the file extension from the end of the name?

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Adding only workbook name to message box

Post by HansV »

Dim strName As String
Dim p As Integer
strName = ActiveWorkbook.Name
p = InStrRev(strName, ".")
strName = Left(strName, p - 1)
MsgBox "Your new report named " & strName & " is ready."
Best wishes,
Hans

ABabeNChrist
SilverLounger
Posts: 1868
Joined: 25 Jan 2010, 14:00
Location: Conroe, Texas

Re: Adding only workbook name to message box

Post by ABabeNChrist »

Thank You Hans :grin: