D
Derek Johansen
Hey everyone!
I have written a macro to import and manipluate a deliminated text file. It
works well, until I try to have the macro save as! The text files are named
by a program and they have trailing spaces at the end. Example: "EAST 7-621
- G1 .txt" I would like to do a few things that I can't figure out,
and I'm hoping for some assistance:
1. Remove those trailing spaces without removing the inner spaces. Would it
work to Trim(Replace(FileName,".txt",""))?
2. I want the macro to check if a certain directory in this case
"s:/PlanSwift Exports/Jobs/" & strInput is present. If it is, it will create
a new directory inside of that "/WallsPlus" where it will save the file. If
the directory is not present, it will create the strInput directory, then
create the /WallsPlus directory, then save the files within that. *** I
understand how to create the directories if they are not present, but I don't
know how do to it conditionally so that it doesn't overwrite, or give a Path
Not Found error!
3. Save As file. When I try to do a simple ActiveWorkbook.SaveAs I get
errors saying I can't save as that file type. I think it's because it's
currently a .txt file, but i'm not sure how to save a .txt as a .xlsx
I hope these questions are clear, and not asking too much! Hope someone can
give me some help, as I'm getting really frustrated not being able to figure
this seemingly simple stuff out!
I have written a macro to import and manipluate a deliminated text file. It
works well, until I try to have the macro save as! The text files are named
by a program and they have trailing spaces at the end. Example: "EAST 7-621
- G1 .txt" I would like to do a few things that I can't figure out,
and I'm hoping for some assistance:
1. Remove those trailing spaces without removing the inner spaces. Would it
work to Trim(Replace(FileName,".txt",""))?
2. I want the macro to check if a certain directory in this case
"s:/PlanSwift Exports/Jobs/" & strInput is present. If it is, it will create
a new directory inside of that "/WallsPlus" where it will save the file. If
the directory is not present, it will create the strInput directory, then
create the /WallsPlus directory, then save the files within that. *** I
understand how to create the directories if they are not present, but I don't
know how do to it conditionally so that it doesn't overwrite, or give a Path
Not Found error!
3. Save As file. When I try to do a simple ActiveWorkbook.SaveAs I get
errors saying I can't save as that file type. I think it's because it's
currently a .txt file, but i'm not sure how to save a .txt as a .xlsx
I hope these questions are clear, and not asking too much! Hope someone can
give me some help, as I'm getting really frustrated not being able to figure
this seemingly simple stuff out!