Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Document Saved (VBA Word 97)

    I have a macro which creates a new word document, and then creates a table within it (5 columns wide ). The table grows to 1890 rows (88 pages). Yeah, it's big. The last command in the module requires the document to be saved. Surprise, it didn't happen.

    I found that the last line of the following snippet of code resets 'activedocument.Saved' from False to True.

    Selection.WholeStory
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text = "^p"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

    I have cured the problem with the following line of code immediately prior to the save command, but am curious as to the root cause of this phenomenum.

    ActiveDocument.Saved = False

    Any thoughts will be greatly appreciated.

    Don
    Regards
    Don

  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: Document Saved (VBA Word 97)

    Not exactly sure, but it's true that some operations which we would consider
    a "dirty" operation requiring a document save, actually do not make the doc dirty.

    Is it possible that a search and replace is one of those operations?
    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
    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: Document Saved (VBA Word 97)

    That makes no sense, and I can't explain it. Occasionally when doing multiple replace operations, I get a warning message relating to the Undo buffer or to saving changes. I can't remember; it has been a long time (or perhaps it no longer happens in Word 2000?) Perhaps this is related to the document being "unsaved" after a replace? Just a random thought.

  4. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Document Saved (VBA Word 97)

    As an aside (because I have nothing valid to say on actual the problem), it gets up my nose the way that recording a find/replace uses the With statement selectively to exclude the first two and last one Selection.Find

    Wouldn't the code be cleaner if it recorded as
    <pre>Selection.WholeStory
    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^p"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    End With</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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