RANJANK3010
03-02-2022, 11:32 AM
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…
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"
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 below 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.
This could be because of the previous post being unclear.
Please dont considered as "Cross Posting"
https://www.msofficeforums.com/word-tables/48540-table-tagging.html#post166102
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
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...
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…
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"
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 below 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.
This could be because of the previous post being unclear.
Please dont considered as "Cross Posting"
https://www.msofficeforums.com/word-tables/48540-table-tagging.html#post166102
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
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...