-
Using VB editor in Word97 I am attempting to write a macro which brings up the File-Open dialog box. The user will then choose a file and the file's path will be stored into a string.
For example:
1. User runs macro.
2. File Open dialog box pops up.
3. User selects the file dummy.txt from the root of the C: drive.
4. The string "C:\dummy.txt" is stored into the variable strPath.
Thanks in advance.
-
You will need to use the Common Dialog control.
First add a reference to Microsoft Common Dialog Control 6.0
Then use the following code:
Sub Macro()
CommonDialog1.Filter = "Text Files (*.txt)|*.txt|"
CommonDialog1.ShowOpen
strPath = CommonDialog1.FileName
End Sub
Hope this helps...