Amzad Mohammad
asked on
How to check sequence of Citations are ordered properly?
How we can check that all elements (i.e. Figure,Box,Table) are mentioned in consecutive order and if not generate the log file?
Thanks,
Amzad
Thanks,
Amzad
The attachment is simply the same text as in the question (no actual figures, tables or text boxes).
Are the figures and text boxes formatted as 'InLine with text' ? If not this might be a bit difficult, We could check where the Anchors are and compare them, though it might be that some of the elements have been dragged away from their Anchor.
Are the figures and text boxes formatted as 'InLine with text' ? If not this might be a bit difficult, We could check where the Anchors are and compare them, though it might be that some of the elements have been dragged away from their Anchor.
ASKER
Hi GrahamSkan,
Here, what we have to check the listing of figure references are in proper order (at the end of the document). We have no connectivity with the citations (somewhere in the document). (Please refer attachment).
Yes, you are right figures and boxes are formatted as "inLine text".
At the end of the document, we have to check either Table, Box & Figure are written in consecutive order or not.
I want to add one more thing Figure can also be mentioned as (FIG, FIGURE, FIGS and Fig)
Thanks.
SampleFigureCitations.docx
Here, what we have to check the listing of figure references are in proper order (at the end of the document). We have no connectivity with the citations (somewhere in the document). (Please refer attachment).
Yes, you are right figures and boxes are formatted as "inLine text".
At the end of the document, we have to check either Table, Box & Figure are written in consecutive order or not.
I want to add one more thing Figure can also be mentioned as (FIG, FIGURE, FIGS and Fig)
Thanks.
SampleFigureCitations.docx
No actual Figures (images) in the sample, so I suppose that you want to check if the list is in the right order according to the numbering, i.e. Figure 1.2 should not appear in the list before Figure 1.1.
ASKER
Yes, I wanted to check if the list is in the right order or not?
Thanks,amzad
Thanks,amzad
OK. I'll work on that
I am sorry. There will be a delay. I had nearly finished the code when something went wrong. I lost the file and the use of Microsoft Office. My activation code is not being accepted. I am trying to get it back without actually buying it again.
ASKER
Thank you so much.
I have got my MS Office back working, so I will try to rewrite what I did last week.
ASKER
After getting notification on my mail I was thinking you did it.
Anyways, thanks for your positive concern.
Anyways, thanks for your positive concern.
See if this is what you need.
Option Explicit
Enum FeatureType
Figure
Box
Table
End Enum
Sub CheckNumbering()
Dim para As Paragraph
Dim snThis(2) As Single
Dim snPrevious(2) As Single
Dim txtPrevious(2) As String
Dim ft As FeatureType
Dim bNumberedPara As Boolean
For Each para In ActiveDocument.Range.Paragraphs 'step through each paragraph
bNumberedPara = True
Select Case UCase(Trim(para.Range.Words.First)) 'check if it starts with relevant word
Case "FIG", "FIGURE", "FIGS"
ft = FeatureType.Figure
Case "BOX"
ft = FeatureType.Box
Case "TABLE"
ft = FeatureType.Table
Case Else
bNumberedPara = False
End Select
If bNumberedPara Then
snThis(ft) = GetListNumber(para.Range)
If snThis(ft) < snPrevious(ft) Then
Writelog Replace(para.Range.Text, vbCr, "") & " should come before " & txtPrevious(ft)
Else
snPrevious(ft) = snThis(ft)
txtPrevious(ft) = Replace(para.Range.Text, vbCr, "")
End If
End If
Next para
End Sub
Function GetListNumber(rng As Range) As Single
Dim ch As Range
Dim iNumberStart As Integer
Dim strParts() As String
Dim strInteger As String
Dim strFraction As String
Set ch = rng.Words.First.Next
If Not IsNumeric(ch.Text) Then
MsgBox "List number missing in " & rng.Text
End
End If
iNumberStart = ch.Start
Do While IsNumeric(ch.Text) Or ch.Text = "."
Set ch = ch.Next
Loop
ch.Start = iNumberStart
'ensure that 1.2 comes before 1.11 by converting to 1.002 and 1.011
strParts() = Split(ch.Text, ".")
strInteger = strParts(0)
strFraction = Right("000" & strParts(1), 3)
GetListNumber = CSng(strInteger & "," & strFraction)
End Function
Sub Writelog(ByVal Text As String)
Dim f As Integer
Dim strFileName As String
strFileName = "num" & Format$(Now, "yy") & Format(Now, "mm") & Format(Now, "dd") & ".log"
Text = Format$(Now, "HH:nn:ss") & " " & Text
Debug.Print Text
f = FreeFile
Open ActiveDocument.Path & "\" & strFileName For Append As #f
Print #f, Text
Close #f
End Sub
ASKER
Hi GrahamSkan,
It is running fine, but got some queries when running it on original documents.
i) What if we get Fig 1.1a, Fig 1.1c and Fig 1.1b
ii) Figure A, Figure C and Figure B
iii) If we get Simply Fig 1, Fig 3 and Fig 2
iv) if we have to check hyphen, ndash, mdash as well, in place of dot(.). i.e. FIG 1-1, FIG 2—2 etc.
v) It is not taking captions as case sensitive.
It is running fine, but got some queries when running it on original documents.
i) What if we get Fig 1.1a, Fig 1.1c and Fig 1.1b
ii) Figure A, Figure C and Figure B
iii) If we get Simply Fig 1, Fig 3 and Fig 2
iv) if we have to check hyphen, ndash, mdash as well, in place of dot(.). i.e. FIG 1-1, FIG 2—2 etc.
v) It is not taking captions as case sensitive.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
ASKER
CheckCitations.docx