Consulting

Results 1 to 3 of 3

Thread: How do I differentiate between two directories in Word VBA?

  1. #1
    VBAX Newbie
    Joined
    Apr 2023
    Posts
    1
    Location

    How do I differentiate between two directories in Word VBA?

    Hello everyone,


    the following code is part of a longer macro:


    Dim TOFRange As Range
    Dim Found As Boolean
    Set TOFRange = ActiveDocument.TablesOfFigures(1).Range
    With TOFRange.Find
       .ClearFormatting
       .Font.Italic = True
       .Font.Bold = True
       .Text = ""
       .Forward = True
       .Wrap = wdFindStop
       Do While .Execute
       If Not TOFRange.InRange(ActiveDocument.TablesOfFigures(1) .Range) Then
          Exit Do
       End If
       TOFRange.Font.Italic = False
       TOFRange.Font.Bold = True
       TOFRange.Collapse wdCollapseEnd
       Loop
    End With
    This part formats a section of my table of figures.

    My plan is to have the same functions for tables. Therefore, I have inserted a table of tables, which is also a TOF. Now my question is: How do I change the above code so that Word knows that I mean the table of tables and not the table of figures? I have already replaced the 1 behind TablesOfFigures with all numbers up to 9, but unfortunately this does not change anything.

    Thank you and have a nice Easter weekend!

    Regards, Jonas
    Last edited by Aussiebear; 04-08-2023 at 04:52 AM. Reason: Added code tags to supplied code

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    Welcome to the VBAX forum Jonas. When suppling code with your post, please wrap the code with code tags. Either highlight your code and then select the # icon or conversely, select the # icon and then insert your code between the tags.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,335
    Location
    Where did "9" come from? Replace the 1 in .TablesOfFigures(1) to 2 in both instances. Note, if all the text in the table of figures or table of tables is Bold\Italic then your macro won't find anything.
    Greg

    Visit my website: http://gregmaxey.com

Posting Permissions

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