Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2022, 05:29 AM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default Table Tagging

In a word document I need to tag “AAA” at the beginning of the table (Above to the Table) and “BBB” at the end of the table (Next to the end of a table).

After running a macro at the beginning of the table it should get tagged as “AAA” then it should be Ask for confirmation at the end of the table as “wish you want to continue the table “Yes” or “No”. if we select yes then it should be move to the next table and again it should be asked for confirmation Yes or No until we select No. if we select No then it should be tagged as “BBB” at the ending of the table.

Although I'm not quite sure if we could automate this work or not, if it doesn't seem realistic, please excuse me…

If it works well, I can modify the code and tagged remaining tables in a document.
I need to tag all the tables in a document based on the table header presentation, there will be a minimum of 40 tables in a document to tag this manually…



I really appreciate your help and my sincere gratitude goes out to you for your support.

Please find the attachment for a sample doc.

Doc Type: ".docx" , ".rtf"
Attached Files
File Type: docx Sample.docx (53.4 KB, 16 views)
Reply With Quote
  #2  
Old 02-21-2022, 09:44 PM
Guessed's Avatar
Guessed Guessed is offline Table Tagging Windows 10 Table Tagging Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this code
Code:
Sub TagTables()
  Dim aTbl As Table, bSkip As Boolean, iCount As Integer, i As Integer
  iCount = ActiveDocument.Tables.Count
  For i = 1 To iCount
    Set aTbl = ActiveDocument.Tables(i)
    aTbl.Select
    If Not bSkip Then
      aTbl.Range.Previous(Unit:=wdCharacter, Count:=1).InsertBefore vbCr & "AAA"
      bSkip = MsgBox("Yes to Extend tag, No to close tag", vbYesNo) = vbYes
      If Not bSkip Then aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
    Else
      bSkip = MsgBox("Yes to Extend tag, No to close tag", vbYesNo) = vbYes
      If bSkip = False Then
        aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
      End If
      If i = iCount - 1 Then bSkip = False
    End If
  Next i
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 02-22-2022, 12:58 AM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

Hi,

It is much appreciated that you responded so quickly...

Its working but the looping was continuing to all the tables in a document even if we select “NO” or “YES”

If we select "YES" it should move to the next table and if we select “No” it should stop looping & tagged “BBB” at the end of that table but here if we select “Yes or No” it was looping all the tables in a document & tagging to the tables.

Tagged AAA at the beginning of the active table, then if we select "Yes" It should moved to next table, again if we select "Yes" it should moved to next table, if we select "No" then it should stop moving to next table and tagged BBB at the end of that table.

It would be appreciated if you reviewed the code once and fixing the issue.
Reply With Quote
  #4  
Old 02-22-2022, 03:21 PM
Guessed's Avatar
Guessed Guessed is offline Table Tagging Windows 10 Table Tagging Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Quote:
After running a macro at the beginning of the table it should get tagged as “AAA” then it should be Ask for confirmation at the end of the table as “wish you want to continue the table “Yes” or “No”. if we select yes then it should be move to the next table and again it should be asked for confirmation Yes or No until we select No. if we select No then it should be tagged as “BBB” at the ending of the table.
...
I need to tag all the tables in a document based on the table header presentation, there will be a minimum of 40 tables in a document to tag this manually…
Your instructions are unclear as to what is the point of the msgbox. Do you want to tag every table with the same AAAtableBBB pattern or have some that go AAAtabletableBBB? I wrote the macro for the latter situation.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #5  
Old 02-22-2022, 08:06 PM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

Hi
Sorry for inconvenience caused to you, I need to tag all tables in a document but tagging text is different. If i get a exact code I can modify the tagging text based on a table headers. I will change a tagging text based on the requirement.

This is actual requirement.

Tagged AAA at the beginning of the active table, then if we select "Yes" It should moved to next table, again if we select "Yes" it should moved to next table, if we select "No" then it should stop moving to next table and tagged BBB at the end of that table.

Please find test document in a attachment.

Thanks....
Reply With Quote
  #6  
Old 02-28-2022, 12:54 PM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

Quote:
Originally Posted by ranjan View Post
Hi

This is actual requirement.

Tagged AAA at the beginning of the active table, then if we select "Yes" It should moved to next table, again if we select "Yes" it should moved to next table, if we select "No" then it should stop moving to next table and tagged BBB at the end of that table.

Please find test document in a attachment.

Thanks....

Not all the tables in a documents, tagged AAA on the active table beginning and it should move to next table based on the input Yes or No, if YES means move to next table and NO means it will not move to next table and tagged BBB at the end of that table.

I would appreciate if you could review the code once based on the above requirements.
Despite my best efforts, I could not modify the code.
I greatly appreciate you helping me and I thank you very much...
Reply With Quote
  #7  
Old 03-02-2022, 01:42 PM
Charles Kenyon Charles Kenyon is offline Table Tagging Windows 10 Table Tagging Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Cross-posted at Tagging


For cross-posting etiquette, please read: A Message to Forum Cross-Posters
Reply With Quote
  #8  
Old 03-11-2022, 11:38 AM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

This is actual requirement.

Tagged AAA at the beginning of the active table, then if we select "Yes" It should moved to next table, again if we select "Yes" it should moved to next table, if we select "No" then it should stop moving to next table and tagged BBB at the end of that table.

Please find test document in a attachment.

Please modify the above code.

I have posted this in the below forum and would like to modify the code to suit my needs but dont seem to be getting any responses.

Tagging


This could be because of the previous post being unclear.

I would appreciate if you could review the code once based on the above requirements.
Despite my best efforts, I could not modify the code.
I greatly appreciate you helping me and I thank you very much...
Reply With Quote
  #9  
Old 03-14-2022, 02:40 PM
ranjan ranjan is offline Table Tagging Windows 10 Table Tagging Office 2019
Advanced Beginner
Table Tagging
 
Join Date: May 2021
Posts: 76
ranjan is on a distinguished road
Default

HI,

Am getting a " run time error 5941:", (The requested member of the collection does not exists.)

This is actual requirement.

Tagged AAA at the beginning of the active table, then if we select "Yes" It should moved to next table, again if we select "Yes" it should moved to next table, if we select "No" then it should stop moving to next table and tagged BBB at the end of that table.

Could you plese review the code once and do the needful.

Code:
Sub Text_Insert()

Dim i As Long, j As Long
Dim rng As Range
If Selection.Information(wdWithInTable) = False Then
    MsgBox "The selection is not inside a table."
    Exit Sub
End If
With ActiveDocument
    For i = 1 To .Tables.Count
        If Selection.Range.Start > .Tables(i).Range.Start And Selection.Range.End < .Tables(i).Range.End Then
            Exit For
       End If
       Next i
       Set rng = .Tables(i).Range
       rng.Collapse wdCollapseStart
       rng.MoveStart wdCharacter, -1
       rng.InsertBefore vbCr & "AAA"
       For j = i + 1 To .Tables.Count
          If MsgBox("Do you wish to insert the End tag after this table", vbQuestion + vbYesNo) = vbYes Then
              Set rng = .Tables(j).Range
              rng.Collapse wdCollapseEnd
              rng.InsertAfter "BBB" & vbCr
             Exit For
         End If
    Next j
End With

End Sub
Your Help is Highly Appreciated and Thanks in Advance..
Reply With Quote
  #10  
Old 03-15-2022, 04:51 PM
Guessed's Avatar
Guessed Guessed is offline Table Tagging Windows 10 Table Tagging Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Assuming you want to start from the current selection position.
Code:
Sub TagTables2()
  Dim aTbl As Table, bSkip As Boolean, iCount As Integer, i As Integer, aRng As Range
  Set aRng = ActiveDocument.Range(Selection.Start, ActiveDocument.Range.End)
  bSkip = False
  iCount = aRng.Tables.Count
  For Each aTbl In aRng.Tables
    i = i + 1
    aTbl.Select
    If bSkip = False Then aTbl.Range.Previous(Unit:=wdCharacter, Count:=1).InsertBefore vbCr & "AAA"
    bSkip = MsgBox("Yes to Extend tag, No to stop and close tag", vbYesNo) = vbYes
    If i = iCount Or Not bSkip Then
      aTbl.Range.Next(Unit:=wdCharacter, Count:=1).InsertBefore "BBB" & vbCr
      Exit For
    End If
  Next aTbl
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Tags
tagging

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Tagging Misspell words ranjan Word VBA 3 08-18-2021 06:02 AM
Word to xml tagging macro ganesang Word VBA 0 03-19-2019 04:10 AM
Table Tagging Need macro for XML tagging in word doc ganesang Word VBA 4 03-13-2019 02:39 AM
Table Tagging Code to find a named (bookmarked?) table, replicate a row or table, and delete a specified table. kevinbradley57 Word VBA 9 09-21-2017 04:58 PM
Macro for tagging and rearranging selected text for revision caotico Word VBA 0 03-28-2012 06:35 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft