partlysunny
08-23-2012, 01:06 PM
Hi all, new to the forum.
We need one of our macros to find a file and read the first line. The file will always be located in either:
"c:\Program Files\Microsoft Office\Templates\"
OR
"c:\Program Files(x86)\Microsoft Office\Templates\"
Right now our code only works for the first scenario, and reads:
Dim configfile As String
' Get the templates path
a$ = "c:\Program Files\Microsoft Office\Templates\"
configfile = a$ & "configfile.txt"
Been playing with detecting whether it's 64-bit using the Environ("ProgramFiles") and Environ("ProgramFiles(86)") variables, but the deeper we get the more unnecessarily complicated it becomes.
Is there an elegant/simple way for the macro to always look for BOTH paths and pass forward the one that's correct? (Btw, we know we shouldn't be hard coding any paths, long story...)
Thanks so much for any insights.
We need one of our macros to find a file and read the first line. The file will always be located in either:
"c:\Program Files\Microsoft Office\Templates\"
OR
"c:\Program Files(x86)\Microsoft Office\Templates\"
Right now our code only works for the first scenario, and reads:
Dim configfile As String
' Get the templates path
a$ = "c:\Program Files\Microsoft Office\Templates\"
configfile = a$ & "configfile.txt"
Been playing with detecting whether it's 64-bit using the Environ("ProgramFiles") and Environ("ProgramFiles(86)") variables, but the deeper we get the more unnecessarily complicated it becomes.
Is there an elegant/simple way for the macro to always look for BOTH paths and pass forward the one that's correct? (Btw, we know we shouldn't be hard coding any paths, long story...)
Thanks so much for any insights.