Extra "." in file name when creating zip file in 2007 with 2003 co

D

David

I have some code that works great in Excel 2003, but in 2007, when creating a
zip file, there is an extra "." in the file name, like filenameZ..zip. It
happens in both the filename inside the zip file AND in the zip file itself.
Here is the suspect code:
FileNameZip = DefPath & Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) -
4) & ".zip"
FileNameXls = DefPath & Left(ActiveWorkbook.Name,
Len(ActiveWorkbook.Name) - 4) & "Z" & ".xlsm"
I've changed the file extension to xlsm, but if I try to change the
FileNameXls to Xlsm, it does not work.
Does anyone have any ideas? I got this code from Ron several years ago.
THanks much!
 
R

RonaldoOneNil

In 2007 the file extensions are 4 characters and not 3 (xlsx and xlsm) so
your code Len(activeworkbook.Name) - 4 is not stripping off the "." anymore.
It needs to be Len(activeworkbook.Name) - 5
 
M

Mike H

David,

File extensions in E2007 are 4 characters .long so your part line
Len(ActiveWorkbook.Name) - 4)

is taking away the xlsm but not the period and because you then add a period
you get 2

Len(ActiveWorkbook.Name) - 5)

should do the trick.

Mike
 
R

Ron de Bruin

Hi David

I see that the macro on my site is not correct
I will update it today and post the link here
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top