![]() |
|
Technology Computing, programming, science, electronics, telecommunications, etc. |
![]() |
|
Thread Tools | Display Modes |
|
![]() |
#1 |
Syndrome of a Down
Join Date: Jun 2001
Location: West Chester
Posts: 1,367
|
That helped quite a bit.
Next puzzler: What built-in routine can I use to check for the existence of a particular style in a document? STYLEREF works great for grabbing the previous reference of a particular style, but I'm looking for a Boolean here. Pseudocode I want to use goes something like this: IF (Style X exists) THEN { (move to next instance of Style X) (perform action, replacing Style X with my new structure) } ENDIF Or WHILE (Style X exists) { (move to next instance of Style X) (perform action, replacing Style X with my new structure) } ...needing it to bail out if the style is no longer present. Word's Find/Replace functionality doesn't seem to want to bail out when in macro form. If I have something like: { FIND (Style X) (Hit Delete key) } bound together, it works great as long as Style X exists. If it doesn't, it ignores the first line and simply executes whatever's in the rest of the routine, instead of kicking out a "Selection not found" error like it would if I searched for it manually. Suggestions? |
![]() |
![]() |
![]() |
#2 |
Syndrome of a Down
Join Date: Jun 2001
Location: West Chester
Posts: 1,367
|
I have everything I need working pretty well in Word 2000, functioning properly almost 100% of the time with proper input.
Naturally, someone tested my code in Word 2002 today, and it fails completely. Bafflingly, Word 2002 seems unable to handle basic Find/Replace functionality that I recorded using Record A Macro in Word 2000. Here's a sample chunk of code that's failing: Code:
Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("Block Label") Selection.Find.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "" .Replacement.Text = "" .Forward = False .Wrap = wdFindAsk .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Do While .Execute (Text manipulation goes here) ' End and repeat the loop until all Units in the doc are done Loop End With Selection.EndKey Unit:=wdStory In Word 2002, the Find _fails_. I've checked the styles on the structures, and they're perfect. I click the icon for my macro and it scans through the document, doesn't find _any_ instances of Block Label <b>even though I can SEE several of them on any given page</b>, and coughs and dies. Is there something about using Find to find text in tables in Word 2002 that I really need to know? (For reference, it's not the loop that's failing. The debugger is pointing to the Find statement itself and returning a "Not found in document" error, and my versions that do them one at a time without looping fail the same way.) |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|