B
Bill
I used to write in VB quite a bit (back in the 90s) but haven't had occasion
to write anything in a while. Now I am trying to get my head back in the
game. After surmounting the loss of Application.FileSearch with six hours of
frustration until I found the Dir() command I thought I would ask a basic
question prior to jumping into the frustration again.
I have a set of files (143) that I have created using VB and three
templates. The files are all named cryptically, for example:
A26Checklist.doc
A27Studyoutline.doc
B01checklist.doc
B02checklist.doc
B03studyoutline.doc
What I would like to do is cycle through the 143 files in the folder, open
each one, take the first three characters of the document name, fill a
variable with a text string based on the first three characters, do a little
searching and replacing with the text string, and then close the document in
question.
I know how to cycle through the files using Dir(pathname & "*.doc). I know
how to use the Mid() command to get my text strings out of the doc.name. I
know how to do the searching and replacing once I have the text string in
variable. But for some reason my aging brain isn't getting the right code
for setting up and populating the array.
I tried to get around the question by just creating a giant "Select Case"
statement, but unfortunately VB won't let me do that inside of the
"For...Next" loop that I wanted to do to go through the Dir()'s.
The 3-character names and text strings all are unique:
A26 = "EmergencyResponse"
A27 = "Board Operation"
B01 = "Unit Overview"
B02 = "Unit Utilities"
B03 = "Tank Gauging"
This seems to be a natural two-dimensional array. The question is how do I
define it and populate it? Then how do I get VB to give me, for example,
"Tank Gauging" for the B03 code?
I did a lot of searching in the internet before I thought to come look into
Microsoft's online community. So perhaps I am just frustrated and should
read all the strings in here.
I would appreciate any help.
Bill Dannenmaier
to write anything in a while. Now I am trying to get my head back in the
game. After surmounting the loss of Application.FileSearch with six hours of
frustration until I found the Dir() command I thought I would ask a basic
question prior to jumping into the frustration again.
I have a set of files (143) that I have created using VB and three
templates. The files are all named cryptically, for example:
A26Checklist.doc
A27Studyoutline.doc
B01checklist.doc
B02checklist.doc
B03studyoutline.doc
What I would like to do is cycle through the 143 files in the folder, open
each one, take the first three characters of the document name, fill a
variable with a text string based on the first three characters, do a little
searching and replacing with the text string, and then close the document in
question.
I know how to cycle through the files using Dir(pathname & "*.doc). I know
how to use the Mid() command to get my text strings out of the doc.name. I
know how to do the searching and replacing once I have the text string in
variable. But for some reason my aging brain isn't getting the right code
for setting up and populating the array.
I tried to get around the question by just creating a giant "Select Case"
statement, but unfortunately VB won't let me do that inside of the
"For...Next" loop that I wanted to do to go through the Dir()'s.
The 3-character names and text strings all are unique:
A26 = "EmergencyResponse"
A27 = "Board Operation"
B01 = "Unit Overview"
B02 = "Unit Utilities"
B03 = "Tank Gauging"
This seems to be a natural two-dimensional array. The question is how do I
define it and populate it? Then how do I get VB to give me, for example,
"Tank Gauging" for the B03 code?
I did a lot of searching in the internet before I thought to come look into
Microsoft's online community. So perhaps I am just frustrated and should
read all the strings in here.
I would appreciate any help.
Bill Dannenmaier