Results 1 to 2 of 2

Thread: File-Open dialog box (VBA)

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    49

    Question

    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.

  2. #2
    Lively Member
    Join Date
    Sep 2000
    Location
    Singapore
    Posts
    78
    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
  •  



Click Here to Expand Forum to Full Width