Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ChDir not working as expected (Word 2000)

    I am creating an index using RD fields (the Index field is in one document with RD fields that reference the documents that should be included in the index). The RD fields do not specify a path because all of the files are in the same directory. For example, {RD "file to be indexed.doc"}

    If I open my index.doc file using File-Open (navigating to the correct directory), then everything works fine. If I happen to open index.doc from Explorer, where I don't navigate using File-Open, then updating the index gives an error, something like "Word cannot find the file C:My Documents|File to be indexed.doc," if Word's default Documents location is C:My Documents.

    I tried writing a macro with the first line being:

    ChDir ActiveDocument.Path

    To me, that should tell Word to change its current path to the location of the open document. If I follow that line up with:

    If CurDir <> ActiveDocument.Path then Stop

    And Word thinks everything is fine. It *thinks* its current path is the right one. If I update my index, though, I still get the error. If I click File-Open after getting the error, C:My Documents is the directory displayed.

    Is there something I'm missing, or is this a bug in the index process? Have I misunderstood the ChDir function?

    Thanks,
    Bob
    Writing Consultant / Word Template Designer
    Words Connect

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: ChDir not working as expected (Word 2000)

    You need to set Options.DefaultFilePath(wdDocumentsPath) to point to the correct location, using a syntax like...
    <pre>Options.DefaultFilePath(wdDocumentsPath) = "C:StuartTemp"
    </pre>

    StuartR

    Edited by StuartR to correct a mistake

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChDir not working as expected (Word 2000)

    Thanks for the quick reply. I would think, though, that this would set the default path, so that every time I start Word, it would default to this directory. I only want the path to be set for the current instance of Word (the "current" path, not the "default" path). This application runs on many different machines and on documents in many different directories. I don't want to continually reset Word's default document directory, and I don't want to change Word's defaults on my client's machines.
    Writing Consultant / Word Template Designer
    Words Connect

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: ChDir not working as expected (Word 2000)

    If it is only for this one occassion then try
    <pre>ChangeFileOpenDirectory("c:StuartTemp")
    </pre>

    StuartR

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    Atlanta, Georgia, USA
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ChDir not working as expected (Word 2000)

    THAT'S what I was looking for!

    Pity that setting isn't linked from ChDir or DefaultFilePath in the Help. I might have found it myself <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Thanks Stuart!
    Writing Consultant / Word Template Designer
    Words Connect

Posting Permissions

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