![]() |
|
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
|
Word 2000 stunt driving me nuts
Any Word or WordBasic gurus out there? I've got an issue that's driving me batty.
My document has a table at the top of each page, containing a handful of cells with specific text styles. I've got a macro worked out that allows me to clone a previous page's header table structure: 1) Page break from insertion point 2) Insert a temporary bookmark to mark my place 3) Search up for a particular style, which appears only in my header tables 4) Select and copy the table 5) Jump to the bookmark 6) Paste the table on the new page 7) Tweak one of the text styles in one block, to avoid a minor TOC issue 8) Delete the temporary bookmark. Easy enough. However, here's what I _really_ want a secondary macro to do: 9) Do 1 through 8 to set up a new page. 10) Set up a bookmark at the page title position. 11) Change the style for that position from Page Title to Page Title Continued (same formatting, just making a style distinction). 12) Search up for the closest Page Title text and copy it. 13) Create a FIELD at the insertion position containing the previous Page Title text. 14) Throw ", page continued" after it on the new page. So that I end up with something like: Page 1: Title blah blah. Page 2: [Title blah blah], page continued. Page 3: [Title blah blah], page continued. Page 4: A new title. Page 5: [A new title], continued. where I can update Page 1, 4, etc. and refresh the document to autoupdate the dependent fields. The stopper is Step 13. Anyone got a hint as to how I'd manage that? |
![]() |
![]() |
![]() |
#3 |
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? |
![]() |
![]() |
![]() |
#4 |
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.) |
![]() |
![]() |
![]() |
#5 |
Syndrome of a Down
Join Date: Jun 2001
Location: West Chester
Posts: 1,367
|
Narrowed down the problem by testing in Word 2002.
I type the word "Potrzebie" in a document somewhere. If I do the following: * Turn on Record A Macro, hit CTRL-F to call up Find, and search for the text string Potrzebie it works, both while recording and as a macro. I change Potrzebie to Heading 6 style. If I do the following: * Turn on Record A Macro, hit CTRL-F to call up Find, and search for the text string Potrzebie it works, both while recording and as a macro. But if I: * Turn on Record A Macro, hit CTRL-F to call up Find, and search for the text style Heading 6, it works when I'm recording but DOES NOT WORK as a macro. This: Code:
Selection.Find.Style = ActiveDocument.Styles("style name here") Thoughts? Workarounds? Icepicks to my skull? |
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|