Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    What could be simpler:
    ChangeFileOpenDirectory str
    With Dialogs(wdDialogFileSaveAs)
    .Name = str
    .Show
    End With

    .. but first time Word comes up it doesn't do the change directory (the directory does exist)
    Next time in the same session it is fine.

    It is not generating an error.
    A msgbox directly after the ChangeFileOpenDirectory show the right directory (but press ok and it brings up SaveAs to the wrong directory - two up)
    Every time it is run in debug mode it works.
    The directory is on the network.
    Thought it might be timing but rough and ready attempts to put in a delay - doesn't fix it.

    Anyone else seen this? More to the point, anyone know how to fix it?

    Thanks,
    Judith

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    Does your path end in a backslash? If not, you're actually trying to set the file name. If it does, you don't need ChangeFileOpenDirectory.

    By the way, I would give the variable another name than str, since Str is a built-in VBA function.

    Dim strPath As String
    strPath = "C:MyFolder"
    With Dialogs(wdDialogSaveAs)
    .Name = strPath
    .Show
    End With

    Also see How to change the directory of the Save As dialog.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Re: ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    Thanks Hans. Actually the variable was strFullPath - but nevermind.

    No neither setting the SaveAs name nor ChangeFileOpenDirectory work first time with Word 2000. It is fine on XP and a subsequent call (even to a different directory) works fine. And it always works in debug mode.

    We'll look at changing to XP I guess. Gulp>

  4. #4
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    Excuse my ignorance, but where do you put the VBA function. I would like to install this but dont know where to put it!

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    I experienced a similar problem in Word 2003. See my <post#=397524>post 397524</post#> and the replies.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 200

    The code above is a fragment of a procedure (AKA a macro) or a function (a kind of procedure that can return a value). VBA procedures/functions can be stored in your Normal.dot template, so they are available all of the time, or in a specific termplate with customized functionality, or in a global template, which is good for distributing your procedures/functions to others.

    If you describe in a bit more detail what you want to do with the above code, you can get more specific recommendations for where to put it.

  7. #7
    2 Star Lounger
    Join Date
    Feb 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 200

    Thanks for getting back to me.

    The last post was placed because I was nto sure where to put the code - in the normal/template macro area or perhaps it has to go in a system file(???) - excuse my ignorance. The code didn't have the standard 'Sub...' lead in so I wasn't sure if it was an autorun macro or similar.

    So the intent of the previous question is - where do I stick the code to gt the functionality decribed in the MVP artical. Any help appreciated.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ChangeFileOpenDirectory intermittent (Word 200

    The basic idea would be:
    - Select Tools | Macro | Macros...
    - Specify where you want the macro to be available in the "Macros in" box.
    - Type a name for the macro in the "Macro name" box. This name should be different from the names already listed.
    - Click Create.
    - The Sub ... and End Sub lines will be created for you. You can copy code from the Lounge, and paste it into the macro, or you can type the code yourself.
    - When done, switch back to Word.
    - You can run the macro by selecting Tools | Macro | Macros..., clicking on the name of the macro, then clicking Run.
    - You can also assign the macro to a custom toolbar button and/or keyboard shortcut using Tools | Customize...

  9. #9
    2 Star Lounger
    Join Date
    Nov 2003
    Location
    Christchurch, Canterbury
    Posts
    122
    Thanks
    27
    Thanked 1 Time in 1 Post

    Re: ChangeFileOpenDirectory intermittent (Word 2000 SP3)

    Thanks Jan. I guess that means there is no point in upgrading to XP <img src=/S/frown.gif border=0 alt=frown width=15 height=15>

Posting Permissions

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