View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
owlnevada owlnevada is offline
external usenet poster
 
Posts: 44
Default File Name string formatting problem

I have a macro routine that processes files serially. When I save the file,
I want to format the name to a standard format. With these names below, I
want them to be changed with some Ucase in the first char postion when it
occurs, then allow for 1-6 digits with some times one leading 0, and text in
Lcase, then the file extension default to Lcase "xlsx".

Existing FName Desired FName

12345+.xlsx 12345+.xlsx 'no change needed
12345abs+.xlsx 12345abs+.xlsx "
12345t.xlsx 12345T.xlsx need UCase at
the 't'
v012345.xlsx V012345.xlsx need Ucase at the
'v'
v012345abs.xlsx V012345abs.xlsx "


I can get part of what I want with this:

FName=Activeworkbook.Name

FName = Lcase(Fname) 'need to account for Ucase and Lcase as above here
with something like Left(FName, Ucase,6, Ucase, 1, Right(lcase, ".")

'something in the wrong order or missing here

What syntax will it take to achieve the desired formats as on the right to
handle any of these generic variations that we run into? I don't find
anything similar in any of these posts.

Any links to advance handling of strings formatting like this would be great.

Thanks in advance.