Office Word Programming >> Newbie question: Active.Documents.Bookmarks.Show.Hidden not found

by gh » Mon, 21 Mar 2005 20:41:19 GMT

Hi,

I'm not programming just tried to use the macro from MS to remove
"hidden bookmarks".

The code is:
---------------------
Sub StripHiddenBookmarks()
Dim i As Long
ActiveDocument.Bookmarks.ShowHidden = True
For i = ActiveDocument.Bookmarks.Count To 1 Step -1
If Left$(ActiveDocument.Bookmarks(i).Name, 4) = "_Toc" Then
ActiveDocument.Bookmarks(i).Delete
End If
Application.ActiveDocument.UndoClear
Next i
ActiveDocument.Bookmarks.ShowHidden = False
End Sub
-----------------

It does not run, it stops at AcitveDocument with the messsage: compile
error expected function or variable.


Thanks for help
regards
Georg



Similar Threads

1. newbie question- bookmark dialog shows OLE_LINK

2. Sample of RIGHT WAY to answer a newbie question - was { Newbie question re word returning boolean}

Thank you Peter for taking the time to spell out the thought 
process in how to define a word. It is too often the case the 
response to a newbie will just be a snippet of 
optimized/optimal/??? code with nothing about the how's and why's 
which led to the particular solution.




Peter Knaggs wrote:
> The requirement to maintain the stack does make this more difficult
> than it need be.  The trick is to work with the data.  If you can
> convert it into a single number, the "on or after" becomes a simple
> greater than test.
> 
> The code given below split the problem into two, the year and then
> the day of the year.  We only need to check the day of the year
> if the year is 1582.  By subtracting 1582 from the given year we
> obtain a value which is either: negative (less than 1582), zero
> (equal to) or positive (later than):
> 
> : greg?    ( m d y -- m d y f )
>   dup      ( m d y y )
>   1582     ( m d y y 1582 )
>   -        ( m d y y-1582 )
> 
> If the year is not 1582 we really only need to check if the year is
> before or after 1582.  So we only need to test if the result is
> positive or negative:
> 
>   dup      ( m d y y-1582 y-1582 )
>   0<>      ( m d y y-1582 f )
>   if       ( m d y y-1582 )
>     0>     ( m d y f )
>   else     ( m d y 0 )
> 
> So we now know the year to be 1582 which means we can move on to
> checking the day of the year.  Rather than dropping the 0 we can
> use it simplify copying the day/month values.
> 
>     2over  ( m d y 0 m d )
> 
> Now we convert the month into a number of days by simply multiplying
> it by 32.  We then add the current day of month to this value.  This
> gives us a unique value to represent the day of the year.  This does
> not have to be exact as we are only using it as a comparison.
> 
>     swap   ( m d y 0 d m )
>     32 *   ( m d y 0 d m*32 )
>     +      ( m d y 0 m*32+d )
> 
> Now we only need to know if the day of the year is later than our
> target day (10 * 32 + 14 = 334).
> 
>     334    ( m d y 0 m*32+d 10*32+14 )
>     >      ( m d y 0 f )
> 
> Finally we need to get rid of the 0 we used railer to simply
> day/month copy.
> 
>     nip    ( m d y f )
>   then
> ;
> 
> Removing all the comments, this gives us:
> 
> : greg?    ( m d y -- m d y f )
>   dup 1582 - dup 0<> if
>     0>
>   else
>     2over swap 32 * + 334 > nip
>   then
> ;
> 
> This has the advantage of being a single definition and avoids using
> the return stack.
> 

3. Newbie Question about clearing bookmarks

4. Newbie question about find and replace

Hello all,
I am trying to run a macro FROM EXCEL that effects the changes in a
WORD doc.  Ie : I want to use the word Find and Replace but call it
from excel...so when I runthe program in excel it makes the changes in
word.  here is the code that I gained from the Macro Recorder in
word...it runs fine but doesnt actually change any fields

any advice?

Sub AddData()


    Dim StringToSearch As String
    Dim counter As Long


    'StringToSearch = "test"


       'Word.Application.WindowState = wdWindowStateMaximize
       Word.Application.Documents.Open ("c:\Temp\destination.doc")


        'Word.Application.ActiveDocument.Range.InsertAfter
        'StringToSearch


Word.Application.ActiveDocument.Range.Find.Replacement.ClearFormatting
          With Word.Application.ActiveDocument.Range.Find
                .Text = "test"
                .Replacement.Text = "Done"
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
            End With
        'Selection.Find.Execute Replace:=wdReplaceAll
        Word.Application.Selection.Find.Execute Replace:=wdReplaceAll

       'Word.Application.ActiveDocument.Save
       'Word.Application.Quit
End Sub

5. Some Fonts not spacing correctly show/hide shows "dot" off center - Microsoft Office

6. If {MergeField Active} = True "Active" "Not Active"

Why won't this work?  How do you specify something to be 
true?  I've tried "1", 1, True, "True"...

If {MergeField Active} = True "Active" "Not Active"

7. Hide/show bookmark through macro - Word VBA

8. Newbie question - how to not see headers and footers

Hi - I'm new to Word on the Mac and I'm having a hard time finding a way to
do something that is simple in Word for PC. When I'm writing I like to
eliminate the blank white space between pages - the header and footer - so
that I can see my text in one continuous scroll.  Is there any way to do
this on Word for the Mac.
Many thanks.
Riel