Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2001
    Location
    Washington, Washington, USA
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    File/Open Glitch (VBA - Word XP)

    One of my clients recently upgraded from Word 97 to Word XP. One of the macros I wrote for them, which works flawlessly in Word 97 and Word 2000, seems broken in Word XP. It is pretty simple. A form prompts the user to select a drive letter and, if known, part of the folder name (entering the client number will bring up all jobs for that client, entering part of a job name will find all jobs with that text in the job name, etc.). A TreeView list on the form then displays the matching folders. The user double-clicks the correct folder, and the file dialog box opens to that folder.

    The glitch: when the day begins, the macro works fine. But after using the macro several times, instead of displaying the File/Open dialog with the folder designated earlier in the macro, the

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File/Open Glitch (VBA - Word XP)

    Karyl,

    One thing I noticed right away is that you are invoking the .show method twice
    in your original code. There's no reason do to that. And maybe Word 97 didn't
    care, but XP does? Not sure. But that's not right.

    The .Show is the "business" method: it does exactly what Word does when the
    dialog is opened via the menu or toobar. Word has control of what the user does,
    not you. See the VBA help for clarification.

    If you want control of the dialog, use .Display. Then, to process the "information"
    returned by the user, use the .Execute method.

    ChangeFileOpenDirectory strPath & strFolder
    With Dialogs(wdDialogFileOpen).Display
    .Name = "*.*"
    .Execute
    End With

    And again, in the New code, if you are going to .Show the dialog, you don't need
    (or want) the .Execute method.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Star Lounger
    Join Date
    Apr 2001
    Location
    Washington, Washington, USA
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: File/Open Glitch (VBA - Word XP)

    Actually, that second "Show" was my fault. It wasn't in the original code. We were playing with the code trying a variety of different things to make it work, and the original didn't get back the way it started after it was commented out. Too bad. I was hoping that was the problem!

    I did try changing from the Show to the Display method in the old version and getting rid of the unnecessary Execute command in the new version (which doesn't support "Display"), and they are going to try them out and see what happens. It is very frustrating because it always works perfectly fine for me, but always starts crashing for them after a few uses. And when it bombs out, it doesn't give any indication of where it is going wrong.

    Here are the new versions:

    New Old Version:
    <pre>ChangeFileOpenDirectory strPath & strFolder
    With Dialogs(wdDialogFileOpen)
    .Name = "*.*"
    .Show
    End With</pre>


    New, New Version
    <pre>Dim dlgOpen As FileDialog
    Set dlgOpen = Application.FileDialog(FileDialogType:=msoFileDial ogOpen)
    With dlgOpen
    .AllowMultiSelect = True
    .InitialFileName = strPath & strFolder
    .FilterIndex = 1
    .Show
    End With

    Set dlgOpen = Nothing</pre>


    Many thanks!

    --Karyl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •