|
-
Sep 20th, 2000, 10:29 AM
#1
Thread Starter
Member
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.
-
Sep 20th, 2000, 11:40 AM
#2
Lively Member
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...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|