Consulting

Results 1 to 10 of 10

Thread: Solved: ClearFormatting method: Can anybody reproduce this problem?

  1. #1
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location

    Solved: ClearFormatting method: Can anybody reproduce this problem?

    I suddenly have encountered a problem using the Clearformatting method via a Word object in a VB 6 DLL.

    So, I tried to reproduce the behavior within Word itself, and was able to do so.

    The first sub below results in an error, the second does not.

    Can anybody reproduce this problem?
    In which version of Word?

    [vba]
    Option Explicit

    Private Sub TestClearFormattingAutomation()
    Dim x As Word.Application
    Set x = New Word.Application
    With x
    .Documents.Add
    With .ActiveDocument.Content.Find
    On Error Resume Next
    .ClearFormatting
    Debug.Print Err.Number, Err.Description
    Err.Clear
    End With
    .ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    End With
    x.quit
    Set x = nothing
    End Sub

    Private Sub TestClearFormattingNoAutomation()
    With Application
    .Documents.Add
    With .ActiveDocument.Content.Find
    On Error Resume Next
    .ClearFormatting
    Debug.Print Err.Number, Err.Description
    Err.Clear
    End With
    .ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    End With
    End Sub
    [/vba]

  2. #2
    VBAX Master TonyJollans's Avatar
    Joined
    May 2004
    Location
    Norfolk, England
    Posts
    2,291
    Location
    All works fine for me in 2003. Ran the first one from both Excel and Word (creating a second instance) - no problems at all.
    Enjoy,
    Tony

    ---------------------------------------------------------------
    Give a man a fish and he'll eat for a day.
    Teach him how to fish and he'll sit in a boat and drink beer all day.

    I'm (slowly) building my own site: www.WordArticles.com

  3. #3
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Thanx, that's what I expected.

    Two weeks ago, my main disk drive died, so I had to replace drive and restore from Retrospect backup.

    I expect that Retrospect screwed up, but no way to prove that, so I guess I need to uninstall and re-install any version of Office that acts up.

    Guess I'll first try a repair.

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Both macros run fine in Word 2002 as well.

  5. #5
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    !Let's see if I can say this tactfully!!

    Restrospect stinks!!

    Apparently, either Retrospect does not properly back up Office or Retrospect does not properly restore files in a disaster recovery!

    I ran a Detect and Repair on Office 2003 and rebooted, problem went away!

  6. #6
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Wow!! I have never had Detect and Repair fix a problem for me. I always wind up reinstalling Office completely.

  7. #7
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    The system is a multiboot system with a different Office installed in each OS.

    I had to do the following:

    1. Run detect and repair for the Office 2003 in the drive that was replaced.
    2. Run detect and repair for Office 2000 in a drive that did not get replaced, this one puzzles me.
    3. Re-install Office 97 in a partition had been clobbered and restored.
    4. Puzzling, but I had to do nothing with Office XP in a partition for which I intentionally deleted ALL the files and ten restored the partition.

    However, I now have the damn Office Assistant in Office 97 and it won't go away even tho I've cleared all the option check boxes.

    I'm not sure where the fault lies. After all, a restore should just be restoring files and not affecting any settings. I'm sure the explanation is simple, but I've wasted so much time the past two weeks recovering things, I sure ain't gonna spend time tracking this down.

    There is a log file from te Office 2003 detect and repair, but it is rather cryptic.

  8. #8
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Although this thread appears to have been marked Solved by someone, the thread is NOT Solved as the underlying issue is that a RESTORE of a drive from a Retrospect backup set and/or replacing a disk drive BEFORE the restore seems to break the Office installation.

    In my case, I was able to fix Office 2000 and Office 2003 with "Detect and Repair", but Office 97 had to be re-installed.

    The original posting follows.
    ------------------------------------------------------
    Quote Originally Posted by Howard Kaikow
    I suddenly have encountered a problem using the Clearformatting method via a Word object in a VB 6 DLL.

    So, I tried to reproduce the behavior within Word itself, and was able to do so.

    The first sub below results in an error, the second does not.

    Can anybody reproduce this problem?
    In which version of Word?

    [vba]
    Option Explicit

    Private Sub TestClearFormattingAutomation()
    Dim x As Word.Application
    Set x = New Word.Application
    With x
    .Documents.Add
    With .ActiveDocument.Content.Find
    On Error Resume Next
    .ClearFormatting
    Debug.Print Err.Number, Err.Description
    Err.Clear
    End With
    .ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    End With
    x.quit
    Set x = nothing
    End Sub

    Private Sub TestClearFormattingNoAutomation()
    With Application
    .Documents.Add
    With .ActiveDocument.Content.Find
    On Error Resume Next
    .ClearFormatting
    Debug.Print Err.Number, Err.Description
    Err.Clear
    End With
    .ActiveDocument.Close savechanges:=wdDoNotSaveChanges
    End With
    End Sub
    [/vba]

  9. #9
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Yes, it was marked solved by an Admin member. We can un-mark it if that better suits the current thread. ??

  10. #10
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    Quote Originally Posted by firefytr
    Yes, it was marked solved by an Admin member. We can un-mark it if that better suits the current thread. ??
    I tried to replace the original posting so folkes would not have to waste time reading the other posts, but because the thread was marked as Solved, instead of replacing the posting, the changed post was added to the end.

    I doubt that we will ever learn why the Restore of files to a drive can cause Office to get broken.

    I also lost the Source Code Control Add-In.
    Makes no sense as the drives were fully restored with the same files.
    But we'll never figger it out!

    I just wanted to forewarn folkes.

Posting Permissions

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