Tutorial on Automating Logos4+ with ComApi in VBA
Comments
-
steve clark said:
This does sound like a Verbum issue.
This should be fixed in 5.2a SR-3. Please let us know if the script now works correctly with Verbum. [:)]
0 -
Dylan Rondeau said:steve clark said:
This does sound like a Verbum issue.
This should be fixed in 5.2a SR-3. Please let us know if the script now works correctly with Verbum.
i am not a Verbum user, but Fr. Devin Roza is a Verbum user.
Thanks Dylan!!!
0 -
Dylan Rondeau said:
This should be fixed in 5.2a SR-3. Please let us know if the script now works correctly with Verbum.
Yes, it now works perfectly. Thank you.
0 -
Have any of you put together VBA code to let you paste simply a Bible verse from a specific translation? Or at least from your highest rated Bible of a certain Bible datatype? It seems that the CopyBibleVerses function doesn't work that way, as it only takes your highest prioritized Bible. I've tried, for example: app.DataTypes.GetDataType("BibleLXX").ParseReference("Gen 1:1") is returning text from my top English Bible. Interestingly, when I look in the VBA Locals window, I can see that Logos is correctly recognizing BibleLXX as a dataset type (it correctly sets the SortTitle to "Bible (LXX-R)", for example).
(FYI, my goal is to write code to select a Bible passage in Word, create a table with three columns, in which the code would put the Hebrew, LXX, and English translation).
BTW, looking through the forum for hits for API, I've seen this particular request to just use the API to write code to insert a Bible verse from a specific translation has been made about 3 or 4 different times, and the best answer I've seen so far is that it's not possible with the API... but I find that hard to believe. Is that the case? Thanks.
0 -
Hi all. I've just found this thread on the API. I played with it for some weeks when it was new and then never went back and did much with it. I really wanted it to directly support pasting commands to the cmd box but it does not.
Anyway, this has inspired me to try again as the last I did was about 2 weeks ago when I installed Visual Studio to this laptop after not having it anywhere for way too long. I did little more than a few buttons to start Logos running, but it was nice to see it again and see Logos 5 pop up on command.
I'll post here or maybe a new thread if or when I have something interesting or useful ...
0 -
I tried it several ways and experienced the same problem: Default Bible Text as output for CopyBibleVerses.GetText but correct DataType in the watch window. I browsed through the Logos4Lib with ObjectBrowser and saw that most Properties are read-only. The only way I see that this could be done is wit:
- LogosDataType.ParseReference
- LogosDataType.ScanForReferences
- LogosDataTypes.LoadReference
- LogosDataType.GetDataType
- LogosApplication.ExecuteUri
I tried the following as a quick solution, but the ExecuteUri also defaults to the last used settings although I specified the DataType
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleBHS.Ge1.1"
Sleep 1000
SendKeys "%P"
Sleep 1000
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleKJV.Ge1.1"
Sleep 2000
SendKeys "%P"
Sleep 1000
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleLXX.Ge1.1"
Sleep 2000
SendKeys "%P"
I also tried several different entrypoints to the problem with no positive results:
Dim CBV As LogosCopyBibleVerses
Dim BVR As LogosCopyBibleVersesRequest
Dim LDTR As LogosDataTypeReference
Dim LDT As LogosDataType
Set CBV = App.CopyBibleVerses
Set BVR = CBV.CreateRequest
Set LDT = App.DataTypes.GetDataType("BibleBHS")
Set LDTR = LDT.ParseReference("Ge1.1")BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
Set LDTR = App.DataTypes.LoadReference("BibleBHS.Ge1.1")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
Set LDTR = App.DataTypes.GetDataType("BibleBHS").ParseReference("Ge1.1")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
0 -
Fr Devin Roza said:
Have any of you put together VBA code to let you paste simply a Bible verse from a specific translation? Or at least from your highest rated Bible of a certain Bible datatype? It seems that the CopyBibleVerses function doesn't work that way, as it only takes your highest prioritized Bible. I've tried, for example: app.DataTypes.GetDataType("BibleLXX").ParseReference("Gen 1:1") is returning text from my top English Bible. Interestingly, when I look in the VBA Locals window, I can see that Logos is correctly recognizing BibleLXX as a dataset type (it correctly sets the SortTitle to "Bible (LXX-R)", for example).
(FYI, my goal is to write code to select a Bible passage in Word, create a table with three columns, in which the code would put the Hebrew, LXX, and English translation).
BTW, looking through the forum for hits for API, I've seen this particular request to just use the API to write code to insert a Bible verse from a specific translation has been made about 3 or 4 different times, and the best answer I've seen so far is that it's not possible with the API... but I find that hard to believe. Is that the case? Thanks.
See a possible Temporary solution at end.
The only entrypoints to the problem I could find seems to be:
- LogosApplication.ExecuteUri
- LogosDataType.ParseReference
- LogosDataType.ScanForReferences
- LogosDataType.GetDataType
- LogosDataTypes.LoadReference
because all other properties are read-only.
Test Results:
- LogosApplication.ExecuteUri
- CopyBibleVerses Window defaults to last used Resource and not the DataType specified in the uri
Code used to test:
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleBHS.Ge1.1"
Sleep 1000
SendKeys "%P"
Sleep 1000
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleKJV.Ge1.1"
Sleep 2000
SendKeys "%P"
Sleep 1000
App.ExecuteUri "logos4:CopyBibleVerses;ref=BibleLXX.Ge1.1"
Sleep 2000
SendKeys "%P"None of the following seems to work either: Actually we don't need to test all permutations of code, I just did it to see if there is a specific entrypoint needed that maybe solves the problem.
- LogosDataType.ParseReference
- LogosDataType.GetDataType
- LogosDataTypes.LoadReference
Code used to test:
Set LDT = App.DataTypes.GetDataType("BibleBHS")
Set LDTR = LDT.ParseReference("Ge2.2")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
Set LDTR = App.DataTypes.LoadReference("BibleBHS.Ge1.1")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
Set LDTR = App.DataTypes.GetDataType("BibleBHS").ParseReference("Ge1.1")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)
Set LDTR = App.DataTypes.LoadReference("BibleBHS.Ge1.1")
BVR.Reference = LDTR
Debug.Print CBV.GetText(BVR)I did not test LogosDataType.ScanForReferences because in a way it's tested with the above.
I can see a slow but working temporary solution to the problem through using SendKeys.
PseudoCode:
- Use ExecuteUri to open CopyBibleVerses to Reference
- Press the Tab key 5 times
- Press Enter
- Type the Resource
- Press Enter
- Press Alt+P (%P) to Copy to Word
- Repeat for each Resource
Use the WinApi sleep between steps to slow down execution if needed { Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) }
This will render a horizontal list for the Reference from each Resource
0 -
If the following is against any EULA, please inform me so that I can remove the post. I prefer to stay with the eula.
Function LoadLayout(LayoutName As String) As Boolean
You need to know the LayoutName to use this. Just thought I'll post a quick solution to get the LayoutNames from Logos. I only show how to get info you may need with a purpose. Remember, don't work with sql if you don't know what you are doing. You may end up breaking Logos. I find this rather helpfull to import stuff into word, excel and some other programs. I can not garantee that this will always work in the future, Logos may decide to change the Folder Structure or to put a password on databases.
- Download and install the SQLite ODBC Driver
- Add an ADODB Reference in VBA (Microsoft ActiveX Data Objects 6.1 Library) I think any version from 2 would work.
- Add a Class Named "CDataBaseHelper"
- Create a form with
- a ListBox named list1 and
- a ComboBox named combo1 and
- a CommandButton named cmdLoad
PASTE INTO CDataBaseHelper:
- Dim conn As ADODB.Connection
- Dim RS As ADODB.Recordset
- Dim Path As String
- Dim UserId As String
- Enum LOGOSDATABASES
- DB_LAYOUTS = 0
- DB_NOTES = 1
- End Enum
- Public Sub LogIn(ByVal LogosDir As String, ByVal UserName As String)
- Path = LogosDir
- 'Get the Users Id
- Set conn = New Connection
- Set RS = New ADODB.Recordset
- conn.Open "Driver={SQLite3 ODBC Driver};Database=" & Path & "\Users\UserManager.db"
- RS.Open "Select * From users Where LogosUserName = '" & UserName & "'", conn
- UserId = RS.Fields("userid").Value
- RS.Close
- conn.Close
- End Sub
- Public Sub ListDirect(ByVal db As LOGOSDATABASES, ByVal Obj As Object)
- If Not (LoggedIn) Then Exit Sub
- Set conn = New Connection
- Set RS = New ADODB.Recordset
- Select Case db
- Case DB_LAYOUTS
- conn.Open "Driver={SQLite3 ODBC Driver};Database=" & Path & "\Documents\" & UserId & "\LayoutManager\layouts.db"
- RS.Open "Select * From Layouts Where IsDeleted=0", conn
- While Not (RS.EOF)
- Obj.AddItem RS.Fields("Title").Value
- RS.MoveNext
- Wend
- Case DB_NOTES
- conn.Open "Driver={SQLite3 ODBC Driver};Database=" & Path & "\Documents\" & UserId & "\Documents\Notes\notes.db"
- RS.Open "Select * From NotesDocuments Where IsDeleted=0", conn
- While Not (RS.EOF)
- Obj.AddItem RS.Fields("Title").Value
- RS.MoveNext
- Wend
- End Select
- RS.Close
- conn.Close
- End Sub
- Private Function LoggedIn() As Boolean
- If Path = "" Or UserId = "" Then
- LoggedIn = False
- Else
- LoggedIn = True
- End If
- End Function
PASTE INTO UserForm (and enter your Logos Path and your UserName as parameters)
- Private Sub cmdLoad_Click()
- Dim db As New CDataBaseHelper
- Dim sPath As String
- Dim sUserName As String
- sPath = ""
- sUserName = "LogosUserName "
- db.LogIn sPath, sUserName
- db.ListDirect DB_LAYOUTS, combo1
- db.ListDirect DB_NOTES, list1
- End Sub
0