Help Converting Microsoft Word Bible to PBB
I worked on editing a few books of a new Khmer (Cambodian) Bible translation and wanted to import the text as a Personal Book in Logos but the formatting of the Word documents I have is quite a bit different than the format needed for PBB. Would anyone happen to have a script or any expertise in converting something like this from Word to PBB:
Thanks in advance for any help you can give.
Comments
-
Have you seen this https://support.logos.com/hc/en-us/articles/360015926452-Personal-Books
0 -
Yes, I've actually made a PB Bible with a verse-per-line document. But this one is more fully formatted and it would probably take years to do the required tags like this:
And so I was hoping others might have done this before and found an easier way and manually typing the tags.
0 -
Not being very helpful, but the easiest way is to export it to html, run a parser, then import it back into Word. Reason is the parser can more easily catch the formatting tightly. I have several Bible parsers that do that; looking at your Khmer example, it'd need a way to catch the book names.
The unhelpful part is I'm currently all offline (PC-wise). But surely there's others that parsed Bibles. Maybe keep bumping it up.
"If myth is ideology in narrative form, then scholarship is myth with footnotes." B. Lincolm 1999.
0 -
Nathan, can you maybe provide a sample of exactly what you need.
If you only want to get Books of the Bible, Chapters and Verses tagged for PBB I can provide you with skeleton VBA code to do the job.
If you can provide a docx sample it would be better because then I can provide code that work on that specific sample that you can then further customize to complete the task.
According to your screenshot:
- Do you have each book in a separate document?
- What style do you use for chapters? (Drop Cap?)
- Are all verses superscript?
If we know these parameters it's much easier to give a quick solution to create PB tagging automatically.
0 -
Nathan Wells said:
Yes, I've actually made a PB Bible with a verse-per-line document. But this one is more fully formatted and it would probably take years to do the required tags like this:
Am working on a bible in that format ([[@bible: etc). What I am doing is entering just the section of Scripture that I am studying and ignoring [for now] the rest. Makes it almost usable.
0 -
Nathan Wells said:
And so I was hoping others might have done this before and found an easier way and manually typing the tags.
Thread => Power Tip: Using variables to Search and Replace in Word
Keep Smiling [:)]
0 -
Thanks everyone for your replies.
I've attached the first three chapters of Matthew here:
And yes, I have each book of the Bible in a separate document. And the Chapter style is Drop Cap and the verses are subscripted.
Thanks for your willingness to help!
0 -
Nathan Wells said:
Thanks everyone for your replies.
I've attached the first three chapters of Matthew here:
And yes, I have each book of the Bible in a separate document. And the Chapter style is Drop Cap and the verses are subscripted.
Thanks for your willingness to help!
Hi Nathan,
Is this a revision of the 1954 Hammond version?
Blessings,
Kevin
0 -
Hi Kevin!
No, this is a new translation from a Japanese group. The New Testament has been released as an app - their facebook page is here https://www.facebook.com/cambodiabtp
I helped edit Mark and John. And I believe once everything is formatted for Logos they will be alright with me sharing it with others who are interested.
Hope you and your family are well!
Blessings,
Nathan
0 -
Hi Nathan,
Interesting that they went back to the old spelling for Jesus Christ. That was why I thought it may be a revision. ព្រះយេស៊ូវគ្រីស្ទ
Praying for you and your team!
Blessings,
Kevin
0 -
PJ,
Would greatly appreciate any help you can give specifically with a skeleton VBA code that would format the books automatically. I realize it's getting close to Christmas, so things are busy, but just wanted to ping in case you had some time to take a look at the sample book I posted and see if it would work.
Thanks again for your time,
NathanPJ said:Nathan, can you maybe provide a sample of exactly what you need.
If you only want to get Books of the Bible, Chapters and Verses tagged for PBB I can provide you with skeleton VBA code to do the job.
If you can provide a docx sample it would be better because then I can provide code that work on that specific sample that you can then further customize to complete the task.
According to your screenshot:
- Do you have each book in a separate document?
- What style do you use for chapters? (Drop Cap?)
- Are all verses superscript?
If we know these parameters it's much easier to give a quick solution to create PB tagging automatically.
0 -
Nathan Wells said:
just wanted to ping in case you had some time to take a look at the sample book I posted and see if it would work
Nathan,
I apologize sincerely, I've been so busy I completely avoided the Forums for a long time. Did you manage to format your documents or do you still need a macro. I think it's possible to code.
If you still need it I'll code it tonight or tomorrow.
0 -
No worries PJ - thanks for checking in. It would be great to have a macro from you, I haven't been able to figure out how to do it myself.
Blessings,
Nathan0 -
Nathan Wells said:
have a macro
Here is a quick draft of a possible solution. It creates a new document to keep the original source document. Currently, it only modify Chapter Numbers by adding a MileStone and Bible reference.
This is how it look as PB in Logos.
I made a few assumptions about your documents. I'm thinking of how to convert superscript and footnotes to PB. I'll look into it after my sermon tomorrow.
I attach the Macro although not complete. Maybe you have some rules, ideas, suggestions or improvements?
'TruthTable
'---------------------------------------------------------------------------------
'1)The English Version of the Book Name is contained in the FileName
'2)Chapter Numbers are on a Single Paragraph
'3)Chapter Number are DropCaps
'4)Verse Numbers are Superscript
'5)One paragraph can contain many verses
'6)The source document doesn't use true dropcaps but a fontsize of 36 for Chapters
Const ChapterFontSize = 36
'---------------------------------------------------------------------------------
'Basic Rule
'1)If you change the ActiveDocument, work from bottom to top
'2)If you copy to a new Document you can work from top to botom
Dim Logos As LogosApplication
Const ApiVersion = 3
Sub Main()
Dim sourceDoc As Document
Dim targetDoc As Document
Start
Set sourceDoc = ActiveDocument
Set targetDoc = Application.Documents.Add
targetDoc.PageSetup.PaperSize = sourceDoc.PageSetup.PaperSize
Copy sourceDoc, targetDoc
End Sub
Sub Copy(source As Document, target As Document)
Dim par As Paragraph
Dim newPar As Paragraph
Dim bookName As String
Dim reference As String
Dim chapter As String
bookName = GetBookName(source)
For Each par In source.Paragraphs
If par.Range.Font.Size = ChapterFontSize Then
'Set newPar = target.Paragraphs.Add
chapter = Trim(par.Range.Text)
On Error GoTo PossibleNewLineChar
'Skip empty rows with fontsize 36
If Asc(chapter) <> 13 Then
reference = Logos.DataTypes.GetDataType("bible").ParseReference(bookName & Space(1) & chapter).Render("long")
With target.Application
.Selection.Style = target.Styles.Item("Heading 1")
.Selection.TypeText "[[@bible:" & reference & "]][[Chapter " & Replace(chapter, Chr(13), "") & ">>" & reference & "]]"
.Selection.TypeParagraph
End With
End If
PossibleNewLineChar:
ElseIf par.Range.Style <> "Footnote" Then
'Fix superscript as verses
With target.Application
.Selection.Style = par.Style
.Selection.TypeText par.Range.Text
'.Selection.TypeParagraph
End With
Else
'2do:Handle Footnotes
With target.Application
.Selection.Style = par.Style
.Selection.TypeText par.Range.Text
'.Selection.TypeParagraph
End With
End If
Next
End Sub
Sub Start()
Dim Launcher As Object
On Error Resume Next
Set Logos = GetObject(, "LogosBibleSoftware.Application")
If Err.Number = 429 Then
On Error GoTo ErrHandler
Set Launcher = CreateObject("LogosBibleSoftware.Launcher")
Launcher.LaunchApplication
While Logos Is Nothing
Set Logos = Launcher.Application
Wend
End If
If Logos.ApiVersion <> 3 Then
If MsgBox("Do you want to ignore the ApiVersion difference", vbYesNo) = vbNo Then
MsgBox "Please fix the ApiVersion and try again", vbInformation
Exit Sub
End If
End If
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
Function GetBookName(doc As Document)
On Error GoTo ErrHandler
Dim DT As LogosDataType
Dim ParsedRef As LogosDataTypeParsedReference
Set DT = Logos.DataTypes.GetDataType("bible")
Set ParsedRef = DT.ScanForReferences(doc.Name).Item(0)
GetBookName = ParsedRef.reference.Details.Book
Exit Function
ErrHandler:
MsgBox Err.Description
End
End Function0 -
Here is a plain Word VBA implementation using regular expressions in the Find and Replace object. This is much faster.
Untagged Verses: Look at Chapter 2 Verse 1. The verse number is not superscript. For this macro to do everything correctly it needs to have the same formatting. But, the amount of verses not tagged is minimal and could be fixed manually.
Warning: This Macro does not create a new Document, it works on the ActiveDocument. Run it on a copy!
2Do: 1) If you want the BookName in the Logos Bible Software content pane you need to add the BookName as Heading 1 at the top of the document and change the macro to style all Drop Cap Chapters to Heading 2. 2) The previous macro above extracted the BookName from the Filename. Combining that with this version you can modify the Main routine to automatically detect Booknames.
Streamlining: If you need some more help on streamlining the conversion process I'll try to help. I actually enjoyed writing this RegEx version.
Run: Main
Enjoy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116Sub Main()
Const BookName As String = "Matthew"
TagChapters (BookName)
WalkChapters (BookName)
End Sub
Sub TagChapters(Optional BookName As String = "Matthew")
'Tag All Chapters of Style Drop Cap
'and change the Style to Heading 1
'[[@Bible:BibleBook Chapter]][[Chapter>>BibleBook Chapter]]
'Add a temp char sequence at end of document
'to help find last chapter
ActiveDocument.Content.InsertAfter ("[]")
ActiveDocument.Range.Start = 0
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("Drop Cap")
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Style = ActiveDocument.Styles.Item("Heading 1")
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "[[@Bible:" & BookName & " \1]]Chapter \1"
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub WalkChapters(Optional BookName As String = "Matthew")
'Select the Content of each Chapter
'and pass control to TagVerses routine
Dim Chapter As Long
Dim NextChapter As Long
Dim lEnd As Long
Selection.HomeKey Unit:=wdStory
Do While Selection.End + 2 < ActiveDocument.Content.End
Chapter = Chapter + 1
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(\])(*)(\[)"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
lEnd = Selection.End
TagVerses BookName, Chapter
NextChapter = Chapter + 1
Selection.GoTo What:=wdGoToHeading, Which:=wdGoToAbsolute, Count:=NextChapter
If Selection.Start = 0 Then Exit Do
Loop
'Remove temp [] from Document
RemoveTag ("[]")
Debug.Print ActiveDocument.Content.End, Selection.End
End Sub
Sub TagVerses(BookName As String, Chapter As Long)
'Tag All Verses of Style Superscipt
'[[@Bible:BibleBook Chapter:Verse]][[Verse>>BibleBook Chapter:Verse]]
Selection.Find.ClearFormatting
With Selection.Find.Font
.StrikeThrough = False
.DoubleStrikeThrough = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Superscript = True
.Subscript = False
End With
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "[[@Bible:" & BookName & Space(1) & Chapter & ":\1]][[\1>>" & BookName & Space(1) & Chapter & ":\1]]"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Sub RemoveTag(Optional tag As String = "[]")
'Remove the temp tag that helped to find the last chapter
Selection.HomeKey Unit:=wdStory
ActiveDocument.Range.Start = 0
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "(\[\])"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub0 -
Thanks so much! I'll start working on the conversion and get back with you if I run into any trouble. Again, thank you so much!
0 -
Bug:
Lines 20 & 82 read: Text = "([0-9]{1,2})".
{1,2} will only recognize 1-2 two digits [0-99].Change 20 & 82: .Text = "([0-9]{1,2,3})".
{1,2,3} will recognize up to three digits [1-999].
0