Macro Code Help
Macro Code Help
(OP)
If I use the code below to strip off the last 6 characters of a file name, what code would I use to capture and store the first two characters of the file name?
filename = Strings.Left(filename, Len(filename) - 6) & "PDF"
My goal is to capture and store the first to characters and then us those characters to set the dir to save a file into.
Thanks.
Todd
filename = Strings.Left(filename, Len(filename) - 6) & "PDF"
My goal is to capture and store the first to characters and then us those characters to set the dir to save a file into.
Thanks.
Todd






RE: Macro Code Help
This will return the first two characters of the string "FileName"
There is probably an easier way to do it, but it works.
RE: Macro Code Help
This just takes the first n characters from the left side of FileName. So if you want to retrieve the first two letters of FileName, use
Strings.Left(FileName, 2)
Strings.Left(FileName, (Len(FileName) - (Len(FileName) - 2))) will work, too. However, if you look closely it's really saying Strings.Left(FileName, x - (x - 2)). x - (x - 2) = 2, so you're back to Strings.Left(FileName, 2).
RE: Macro Code Help
RE: Macro Code Help
have a great weekend.
Todd