PDA

View Full Version : Solved: ClearFormatting method: Can anybody reproduce this problem?



Howard Kaikow
01-27-2005, 06:42 AM
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?


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

TonyJollans
01-27-2005, 06:53 AM
All works fine for me in 2003. Ran the first one from both Excel and Word (creating a second instance) - no problems at all.

Howard Kaikow
01-27-2005, 07:10 AM
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.

Jacob Hilderbrand
01-27-2005, 07:17 AM
Both macros run fine in Word 2002 as well.

Howard Kaikow
01-27-2005, 07:33 AM
!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!

Jacob Hilderbrand
01-27-2005, 07:35 AM
Wow!! I have never had Detect and Repair fix a problem for me. I always wind up reinstalling Office completely.

Howard Kaikow
01-27-2005, 10:08 AM
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.

Howard Kaikow
01-28-2005, 03:46 PM
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.
------------------------------------------------------

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?


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

Zack Barresse
01-28-2005, 03:58 PM
Yes, it was marked solved by an Admin member. We can un-mark it if that better suits the current thread. ??

Howard Kaikow
01-28-2005, 05:38 PM
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.