View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Diddy Diddy is offline
external usenet poster
 
Posts: 155
Default Filename str cut too short

Hi Rick,

No they don't. How do I change the code to suit my workbook names?
C:\Documents and Settings\diddy\My Documents\Data\Plot1\yr2 Data 2009

Cheers
Diddy (feeling dopey)

"Rick Rothstein" wrote:

Do you workbook names have dots in them?

--
Rick (MVP - Excel)


"Diddy" wrote in message
...
Hi everyone,

I've nabbed this bit of code off the web and I'm using it with Chip
Pearson's code that loops through files in a folder to change the tab name
into the file name. All workbooks have only one sheet and code is working
fine except that it is cutting the filename too short. I don't understand
how
the Left and -1 are working but think that the intention is to remove the
path and file extension.

If that's what the left and -1 are doing then why does the filename get
shortened?
Could any kind person please explain how this is working and show me how
to
amend to give the unshortened filename without path and extension?

Thanks
Diddy

Sub renametabaswkbkname(myWB As Workbook)
On Error Resume Next
ActiveSheet.Name = Left(ActiveWorkbook.Name, Application.Find(".",
ThisWorkbook.Name) - 1)
myWB.Close savechanges:=True
End Sub