I searched the internet on automating the ComApi in VBA/VBS with little results. The best samples is mostly in C/C++ or something. Here is something that may be of interest and help. If anyone can provide some code samples it would be appreciated.
7318.L4VBATut.zip
What is this bit about "This Tutorial requires LogosCom.exe"?
There is no such file in all of Logos. The executable file for Logos is called Logos.exe.
Yes, that is true in a way. But technically, LogosCom.exe is the ComApi Type Library of Logos. When you add a Reference to the "Logos Bible Software 4 Type Library" in a VBA Project, it is actually pointing to the ActiveX (LogosCom.exe) on your harddrive at %your Logos installation folder% \System\LogosCom.exe and not Logos.exe. Without the Type Library you can't interface with Logos.exe
If for any random reason VBA or your Development Environment of choice says "Can't create ActiveX" you will know that this file either doesn't exist, is not properly registered or you do not have the right security privalages on the file or its directory structure. It's good to know this when working with the ComApi. I encountered this error several times in VBA, VBScript, JScript and .NET 2010 Express Edition on Win 7 and 8.
I hope this explains the use of the filename LogosCom.exe
Nice tutorial! I like the way you put it together. I haven't looked at all the code samples in depth, just flipped through and ran a few of them. Looks very useful and very nicely put together.
Randy, can you give a video demo?
Sure. Here's a real quick screencast of the some of the power point tutorial. You may have to pause to examine some of the screens in more depth.
8037.Logos 4 COM API.zip
Programming the ComApi starts with a workable Knowledge of how Objects attach to each other. Here is my interpretation of the ObjectModel ApiVersion 3. If for any reason I made a mistake on this map, please inform me to make the corrections. If you follow the links and info on this map you should be well away on interfacing with Logos. Start at the Left Node "StartUp" and follow the map to the right. Be carefull in using recursive programming on the LogosDataTypeReference because it returns properties containing LogosDataTypeReference (See the Green nodes).
I Paste some Code here for those that can't use or open VBA. The ClassModule have Functions that could be reused in some situations.
PASTE THIS IN A CLASSMODULE IN VBA
'Win32API - Just used for a Timer in Windows
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)Dim Launcher As LogosLauncherDim WithEvents Logos As LogosApplicationConst ApiVersion = 3Const ClassName As String = "CLogos"Public Event CopyBibleVerse(Reference As String, BibleText As String)Public Event LibraryQuery(ResourceInfo As LogosResourceInfo)Public Event AOpenPanel(Panel As LogosPanel)Public Enum RenderStyles rsSHORT = 0 rsMEDIUM = 1 rsLONG = 2 rsDEFAULT = 3End EnumPublic Enum QueryDetails qdIMAGE = 0 qdTITLE = 1 qdTYPE = 2 qdSERIES = 3 qdSUBJECTS = 4 qdAUTHER = 5 qdMYTAGS = 6 qdRATING = 7 qdABTEVIATEDTITLE = 8 qdELECTRONICPUBLICATIONDATE = 9 qdLANGUAGES = 10 qdPUBLICATIONDATE = 11 qdPUBLISHER = 12 qdLASTUPDATED = 13 qdDEVICES = 14 qdEDITION = 15 qdLASTACCESSED = 16 qdMOSTUSED = 17 qdCOMMUNITYTAGS = 18End EnumSub Create(Optional CommandLineArguments As String) On Error GoTo ErrHandler Set Launcher = New LogosLauncher Set Logos = Nothing Stop Launcher.LaunchApplication CommandLineArguments While Logos Is Nothing Set Logos = Launcher.Application Wend If Logos.ApiVersion < ApiVersion Then _ MsgBox "ApiVersion " & ApiVersion & _ " Required." & vbCrLf & _ "You have " & Logos.ApiVersion & vbCrLf & _ "The Logos Class may not Function correctly", vbCritical, ClassName Exit SubErrHandler: MsgBox Err.Number & " - " & Err.Description Err.ClearEnd SubPublic Function GetResourceInfo(ResourceId As String) As LogosResourceInfo Stop Set GetResourceInfo = Logos.Library.GetResourceInfo(ResourceId)End FunctionProperty Get Application() As LogosApplication If Logos Is Nothing Then MsgBox "Use Create first", vbInformation, Title Else Set Application = Logos End IfEnd PropertySub CopyBibleVerses(BibleReferences As String, Optional RenderStyle As RenderStyles = rsDEFAULT) Dim LDTPRC As LogosDataTypeParsedReferenceCollection Dim LDTPR As LogosDataTypeParsedReference Dim LCBVR As LogosCopyBibleVersesRequest If Logos Is Nothing Then GoTo NoLogos 'Scan first to check if there is more than one Stop Set LDTPRC = Logos.DataTypes.GetDataType("Bible").ScanForReferences(BibleReferences) If LDTPRC.Count > 0 Then For Each LDTPR In LDTPRC Set LCBVR = Logos.CopyBibleVerses.CreateRequest LCBVR.Reference = LDTPR.Reference RaiseEvent CopyBibleVerse(LDTPR.Reference.Render(GetRenderStyle(RenderStyle)), Logos.CopyBibleVerses.GetText(LCBVR)) Next Else 'This will not run because all refrences are handled above 'This is only to show how to do a CopyBibleVerseRequest 'with one Reference another way Set LCBVR = Logos.CopyBibleVerses.CreateRequest LCBVR.Reference = Logos.DataTypes.GetDataType("Bible").ParseReference(BibleReferences) RaiseEvent CopyBibleVerse(LCBVR.Reference.Render(GetRenderStyle(RenderStyle)), _ Logos.CopyBibleVerses.GetText(LCBVR)) End If Exit SubNoLogos: MsgBox "Use Create First", vbInformation, TitleErrHandler: MsgBox Err.Number & " - " & Err.Description Err.ClearEnd SubPrivate Function GetRenderStyle(rs As RenderStyles) As String Stop Select Case rs Case rsSHORT GetRenderStyle = "short" Case rsMEDIUM GetRenderStyle = "medium" Case rsLONG GetRenderStyle = "long" Case rsDEFAULT GetRenderStyle = "default" End SelectEnd FunctionSub QueryLibraryByDetails(QueryByDetail As QueryDetails, SearchString As String) Dim strDetail As String: getQueryDetail (querybydetails) Dim RIC As LogosResourceInfoCollection Dim RI As LogosResourceInfo Stop Set RIC = Logos.Library.GetResourcesMatchingQuery(getQueryDetail(QueryByDetail) & SearchString) For Each RI In RIC RaiseEvent LibraryQuery(RI) NextEnd Sub Sub QueryLibraryByResourceType(ResourceType As String) Dim RIC As LogosResourceInfoCollection Dim RI As LogosResourceInfo Stop Set RIC = Logos.Library.GetResourcesByResourceType(ResourceType) For Each RI In RIC RaiseEvent LibraryQuery(RI) Next End SubPrivate Function getQueryDetail(qd As QueryDetails) As String Select Case qd Case qdIMAGE getQueryDetail = "Image:" Case qdTITLE getQueryDetail = "Title:" Case qdTYPE getQueryDetail = "Type:" Case qdSERIES getQueryDetail = "Series:" Case qdSUBJECTS getQueryDetail = "Subjects:" Case qdAUTHER getQueryDetail = "Auther:" Case qdMYTAGS getQueryDetail = "MyTags:" Case qdRATING getQueryDetail = "Rating:" Case qdABTEVIATEDTITLE getQueryDetail = "AbbreviatedTitle:" Case qdELECTRONICPUBLICATIONDATE getQueryDetail = "ElectronicPublicationDate:" Case qdLANGUAGES getQueryDetail = "Languages:" Case qdPUBLICATIONDATE getQueryDetail = "PublicationDate:" Case qdPUBLISHER getQueryDetail = "Publisher:" Case qdLASTUPDATED getQueryDetail = "LastUpdated:" Case qdDEVICES getQueryDetail = "Devices:" Case qdEDITION getQueryDetail = "Edition:" Case qdLASTACCESSED getQueryDetail = "LastAccessed:" Case qdMOSTUSED getQueryDetail = "MostUsed:" Case qdCOMMUNITYTAGS getQueryDetail = "CommunityTags:" End SelectEnd FunctionSub GetOpenPanels() Dim OP As LogosPanel For Each OP In Logos.GetOpenPanels RaiseEvent AOpenPanel(OP) NextEnd SubPrivate Sub Logos_Exiting() StopEnd SubPrivate Sub Logos_PanelActivated(ByVal Panel As Object) StopEnd SubPrivate Sub Logos_PanelChanged(ByVal Panel As Object, ByVal Hint As Object) StopEnd SubPrivate Sub Logos_PanelClosed(ByVal Panel As Object) StopEnd SubPrivate Sub Logos_PanelOpened(ByVal Panel As Object) StopEnd SubFunction GetNavigationRequestFromActivePanel() Stop 'First I'll open the esv Bible 'I use LoadReference to get the ref to Gen 1:1 formatted for ExecuteUri 'You can use "bible.Gen 1:1" and there is other ways to get to this ref as well 'This is just to show how to use LoadReference 'and to open a Resource for the Navigation Sample Debug.Print Logos.DataTypes.LoadReference("bible.Gen 1:1").Save Logos.ExecuteUri "logosres:esv;ref=" & Logos.DataTypes.LoadReference("bible.Gen 1:1").Save Stop 'With the following code you should keep in mind 'There are different kinds of Panels Dim AP As LogosPanel Dim NR As LogosNavigationRequest 'Take note that the following will contain info for 'Reference Or Headword 'This means the info inside LogosReferenceOrHeadwordCollection and LogosReferenceOrHeadword 'may be either Reference OR Headword Dim HC As LogosReferenceOrHeadwordCollection Dim H As LogosReferenceOrHeadword Set AP = Logos.GetActivePanel If AP.DetailsKind = "Resource" Then Debug.Print "Now we know we can use Panel.Details" Debug.Print "It Return LogosResourcePanelDetails containing the ResourceId: " & AP.Details.ResourceId Set NR = Logos.CreateNavigationRequest Set HC = AP.GetCurrentReferencesAndHeadwords If HC.Count > 0 Then With NR .Headword = HC.Item(0).Headword .HeadwordLanguage = HC.Item(0).HeadwordLanguage .Reference = HC.Item(0).Reference .ResourceId = AP.Details.ResourceId End With End If Stop 'I'll Close All in Logos so we can See the Navigation take place Logos.Activate SendKeys "%D", True SendKeys "Close All", True Sleep 2000 SendKeys "{ENTER}", True Stop Logos.Navigate NR Stop 'We can use the Info from the Panel to create an Uri Debug.Print "logosres:" & NR.ResourceId & ";ref=" & NR.Reference.Save 'We can use that Uri to ExecuteUri Stop 'I'll Close All in Logos so we can See the ExecuteUri take place Logos.Activate SendKeys "%D", True SendKeys "Close All", True Sleep 2000 SendKeys "{ENTER}", True Stop Logos.ExecuteUri "logosres:" & NR.ResourceId & ";ref=" & NR.Reference.Save End If Stop 'The above is a Startingpoint for a more complex way 'to generate NavigationRequests or Uri's for different Panels 'eg: logos4:Explorer;ref=BibleESV.Ge1.1 using logos4:(Panel.Kind obtained) 'This way you can generate Uri's for external links from Active Panels 'Just use your imagination End Function
PASTE THIS IN A FORM IN VBA
Public WithEvents Logos As CLOgosPrivate Sub Logos_AOpenPanel(Panel As Logos4Lib.LogosPanel) Debug.Print Panel.TitleEnd SubPrivate Sub Logos_CopyBibleVerse(Reference As String, BibleText As String) Debug.Print Reference & vbCrLf & vbTab & BibleTextEnd SubPrivate Sub Logos_LibraryQuery(ResourceInfo As Logos4Lib.LogosResourceInfo) Debug.Print ResourceInfo.Title StopEnd SubPrivate Sub UserForm_Initialize() MsgBox "This shows the complicated part of ComApi" & vbCrLf & _ "The rest seems to be easy and straight forward" Set Logos = New CLOgos Stop 'Create Logos Logos.Create Stop 'Single Reference Logos.CopyBibleVerses "Joh 3:16", rsMEDIUM Stop 'Or Multiple References Logos.CopyBibleVerses "Gen 1:1 AND maybe Rev 4:8 and Lev 4:3", rsLONG Stop 'Library Query Logos.QueryLibraryByDetails qdTITLE, "Bible" Stop 'Library Query By ResourceType Logos.QueryLibraryByResourceType "text.monograph" Stop 'The following is to demonstrate how to get ResourceInfo 'using ResourceId Dim RI As LogosResourceInfo Set RI = Logos.GetResourceInfo("LLS:1.0.710") Debug.Print RI.Title, RI.ResourceId 'Not the ResourceId returned by ResourceInfo.ResourceId Set RI = Logos.GetResourceInfo("esv") If RI Is Nothing Then Debug.Print "Returned NOTHING" Stop 'How to Use GetOpenPanels Logos.GetOpenPanels Stop 'I'll demonstrate Application.CreateNavigationRequest and 'Application.Navigate using GetActivePanel Logos.GetNavigationRequestFromActivePanel End Sub
RUN THE FORM
It will Pause itself throughout the Code to show you how to use the API
Interesting Pieter
Especially the part of the code which inserted text into L4's command box, but it was not executed in L4.
EDIT: text from DbugPrint 4428.Pieter's dump to debug.txt
The execution of the SendKeys could cause trouble depending on the speed of your system. Type in "Close All" in your CommandBox and take note of the time delay until the dropdown lists the Close All command. Use that time delay x 1000 in the Sleep command. That should be the delay you normally need.
Logos.Activate SendKeys "%D", True SendKeys "Close All", True Sleep [TimeDelay in milliseconds] SendKeys "{ENTER}", True
Another reason could also be that in those 2 sec delay you probably switched focus to VBA. To make sure the command gets to Logos, insert an Actiavte command before the {ENTER}:
Sleep [TimeDelay in milliseconds]
Logos.Activate SendKeys "{ENTER}", True
Suppose I need to read the Logos Help Manual before trying to use SendKeys.Here is a Class to SendKeys a better way.
WARNING: Do not Break into the CDoCmd.DoCmd Procedure and debug because if Logos doesn't have Focus the Keystrokes will be send to VBA. Rather just check if the SendKeys Keystrokes are correct because I did not check them all, I just wrote them quickly.
Sample: Logos.DoCmd kbs_close_all_panels
Preparations in CLogos Class:Add to the Globals of CLogos Class: Dim KBS As CDoCmdIn CLogos Class at Sub Create(Optional CommandLineArguments As String), Add: Set KBS = New CDoCmdIn CLogos Add:Public Sub DoCmd(eKBS As LogosKeyboardShortCuts) KBS.DoCmd eKBS, LogosEnd Sub
A New Class CDoCmd:Add The Following Class in VBA with the name CDoCmd'SENDKEYS FOR LOGOS4+Public Enum LogosKeyboardShortCuts kbs_activate_window_menu = 0 kbs_add_current_location_to_Favorites = 1 kbs_apply_visual_markup = 2 kbs_clone_this_panel_in_a_new_tab = 3 kbs_close_current_panel = 4 kbs_close_panel = 5 kbs_close_all_panels = 6 kbs_close_program = 7 kbs_copy = 8 kbs_copy_ins = 9 kbs_cut = 10 kbs_cut_del = 11 kbs_delete = 12 kbs_dismiss_or_exit_drawing_mode = 13 kbs_enter_drawing_mode_or_clear_drawing = 14 kbs_erase_visual_markup = 15 kbs_expand_all_timeline_groups = 16 kbs_forces_sign_in_prompt_at_startup = 17 kbs_go_to_Command_Box = 18 kbs_go_to_Home_Page_from_a_floating_window = 19 kbs_switch_home = 20 kbs_go_to_menu_bar = 21 kbs_go_to_next_tab = 22 kbs_go_to_previous_tab = 23 kbs_go_to_reference_box_of_current_resource_OR_guide = 24 kbs_help = 25 kbs_next = 26 kbs_next_equivalent_resource = 27 kbs_open_History = 28 kbs_open_Library_in_a_floating_window = 29 kbs_open_Search_from_a_floating_window = 30 kbs_open_Search_panel = 31 kbs_open_OR_close_Customize_home_page_menu = 32 kbs_open_OR_close_File_menu = 33 kbs_open_OR_close_Guides_menu = 34 kbs_open_OR_close_Help_menu = 35 kbs_open_OR_close_Home_Page = 36 kbs_open_OR_close_Layouts = 37 kbs_open_OR_close_Library = 38 kbs_open_OR_close_Tools_menu = 39 kbs_paste = 40 kbs_paste_ins = 41 kbs_previous = 42 kbs_previous_equivalent_resource = 43 kbs_print = 44 kbs_quick_comparison_of_the_active_verse_OR_selected_text = 45 kbs_redo = 46 kbs_refresh = 47 kbs_search_for_word_OR_phrase_in_Entire_Library = 48 kbs_search_for_word_OR_phrase_in_Top_Bibles = 49 kbs_select_all = 50 kbs_set_Bookmark_1 = 51 kbs_switch_keyboard_focus_to_next_panel = 52 kbs_switch_keyboard_focus_to_previous_panel = 53 kbs_switch_to_next_tab = 54 kbs_switch_to_previous_tab = 55 kbs_undo = 56 kbs_undo_z = 57 kbs_zoom_in = 58 kbs_zoom_out = 59 kbs_zoom_to_fit = 60 kbs_copy_location_as_URL_HTML_WIKI_RL = 61 kbs_find_in_this_panel = 62 kbs_read_aloud = 63 kbs_reading_view = 64 kbs_show_OR_hide_interlinear_pane = 65 kbs_show_OR_hide_locator_bar = 66 kbs_show_OR_hide_table_of_contents = 67End EnumPublic Sub DoCmd(KBS As LogosKeyboardShortCuts, L As LogosApplication) L.Activate Select Case KBS Case kbs_activate_window_menu: SendKeys "% ", True Case kbs_add_current_location_to_Favorites: SendKeys "^d", True Case kbs_apply_visual_markup: SendKeys "^k", True Case kbs_clone_this_panel_in_a_new_tab: SendKeys "^+n", True Case kbs_close_current_panel: SendKeys "^{F4}", True Case kbs_close_panel: SendKeys "^w", True Case kbs_close_all_panels: SendKeys "^+w", True Case kbs_close_program: SendKeys "%{F4}", True Case kbs_copy: SendKeys "^c", True Case kbs_copy_ins: SendKeys "^{INS}", True Case kbs_cut: SendKeys "^x", True Case kbs_cut_del: SendKeys "+{DEL}", True Case kbs_delete: SendKeys "{DEL}", True Case kbs_dismiss_or_exit_drawing_mode: SendKeys "{Esc}", True Case kbs_enter_drawing_mode_or_clear_drawing: SendKeys "{F8}", True Case kbs_erase_visual_markup: SendKeys "^+k", True Case kbs_expand_all_timeline_groups: SendKeys "^e", True Case kbs_forces_sign_in_prompt_at_startup: SendKeys "^", True Case kbs_go_to_Command_Box: SendKeys "%d", True Case kbs_go_to_Home_Page_from_a_floating_window: SendKeys "%{HOME}", True Case kbs_switch_home: SendKeys "{F10}", True Case kbs_go_to_menu_bar: SendKeys "%", True Case kbs_go_to_next_tab: SendKeys "^{TAB}", True Case kbs_go_to_previous_tab: SendKeys "^+{TAB}", True Case kbs_go_to_reference_box_of_current_resource_OR_guide: SendKeys "^g", True Case kbs_help: SendKeys "{F1}", True Case kbs_next: SendKeys "%{DOWN}", True Case kbs_next_equivalent_resource: SendKeys "^+{RIGHT}", True Case kbs_open_History: SendKeys "^h", True Case kbs_open_Library_in_a_floating_window: SendKeys "^l", True Case kbs_open_Search_from_a_floating_window: SendKeys "^+s", True Case kbs_open_Search_panel: SendKeys "%s", True Case kbs_open_OR_close_Customize_home_page_menu: SendKeys "%c", True Case kbs_open_OR_close_File_menu: SendKeys "%f", True Case kbs_open_OR_close_Guides_menu: SendKeys "%g", True Case kbs_open_OR_close_Help_menu: SendKeys "%p", True Case kbs_open_OR_close_Home_Page: SendKeys "%h", True Case kbs_open_OR_close_Layouts: SendKeys "%a", True Case kbs_open_OR_close_Library: SendKeys "%l", True Case kbs_open_OR_close_Tools_menu: SendKeys "%t", True Case kbs_paste: SendKeys "^v", True Case kbs_paste_ins: SendKeys "+{INS}", True Case kbs_previous: SendKeys "%{UP}", True Case kbs_previous_equivalent_resource: SendKeys "^+{LEFT}", True Case kbs_print : SendKeys "^p", True Case kbs_quick_comparison_of_the_active_verse_OR_selected_text: SendKeys "{F7}", True Case kbs_redo: SendKeys "^y", True Case kbs_refresh: SendKeys "{F5}", True Case kbs_search_for_word_OR_phrase_in_Entire_Library: SendKeys "^+{ENTER}", True Case kbs_search_for_word_OR_phrase_in_Top_Bibles: SendKeys "^{ENTER}", True Case kbs_select_all: SendKeys "^a", True Case kbs_set_Bookmark_1: SendKeys "^+1", True Case kbs_switch_keyboard_focus_to_next_panel: SendKeys "^{F6}", True Case kbs_switch_keyboard_focus_to_previous_panel: SendKeys "^+{F6}", True Case kbs_switch_to_next_tab: SendKeys "^{PGDN}", True Case kbs_switch_to_previous_tab: SendKeys "^{PGUP}", True Case kbs_undo: SendKeys "%{BACKSPACE}", True Case kbs_undo_z: SendKeys "^z", True Case kbs_zoom_in: SendKeys "^=", True Case kbs_zoom_out: SendKeys "^-", True Case kbs_zoom_to_fit: SendKeys "^0", True Case kbs_copy_location_as_URL_HTML_WIKI_RL: SendKeys "^%c", True Case kbs_find_in_this_panel: SendKeys "^f", True Case kbs_read_aloud: SendKeys "^r", True Case kbs_reading_view: SendKeys "{F11}", True Case kbs_show_OR_hide_interlinear_pane: SendKeys "^+r", True Case kbs_show_OR_hide_locator_bar: SendKeys "^+l", True Case kbs_show_OR_hide_table_of_contents: SendKeys "^+c", True End SelectEnd Sub
Back in CLogos:In Class CLogos, replace: Logos.Activate SendKeys "%D", True SendKeys "Close All", True Sleep 2000 SendKeys "{ENTER}", TrueWith: DoCmd kbs_close_all_panels
How to Use:Now from the Form you can use: Logos.DoCmd kbs_close_all_panelsYou can use this class in any app with the following Syntax: DoCmd LogosKeyBoardShortCuts, LogosApplication
This is incredibly useful - thanks for sharing! I have been wondering if such a thing was possible with Logos.
I have been unable to make this work, however - I imagine because I am using Verbum??
I have the LogosCom.EXE file, and the reference appears correctly in VBA to the file. However, whenever the code gets to:
oLauncher.LaunchApplication
it returns error 13, "Type Mismatch". Then if I go into Debug mode, and run through the code line by line, at oLauncher.LaunchApplication it gives the error: "Method 'LaunchApplication' of object 'ILogosLauncher' failed" (Run-time error -2147417851 (80010105).
This happens regardless if Verbum is open or not. Any ideas?
I could only advise you on how I would start debugging if I ran into this error. The following is by no means expert advice or even technically correct.
I used Logos Bible Software 5.2a SR-1 (5.2.1.0081) with Api Version 3 (5.2.1.81). I do not know if the ComApi also updates automatically.
I would try to Create the Launcher with late binding first (I did not test this, just wrote it here):
Sub Test()
Dim oLauncher 'DO NOT USE As LogosLauncher HERE
on error goto ErrHandler
Set oLauncher = CreateObject("LogosBibleSoftware.Launcher") 'The version independent ProgID
Beep 'If we get here it works"
stop
Exit Sub
ErrHandler:
Beep: Beep
Debug.Print Err.Number & " - " & Err.Description
End Sub
If this worked, search if there is another LogosCom.exe file on your system.
Hope this directs you into a meaningfull debug session.
When i copied Pieter's code (a few posts above), i had to:
Here is my Excel file with Pieter's stuff (class renamed) 3443.Book1.zip(had to zip the Excel file because the forum editor doesn't allow files with macros, so you will need to unzip the file.
More steps
It is working now, i had to allow more time since i am running on a slow computer (see my PC specs below in my signature).
Thanks Pieter for your hard work!
btw, how do you see this api being used inside of an Office app? i am curious.
It seems you can use it to copy Bible verses, open a panel inside of L4, get book names in your library. Guess i am not looking outside the box to see how i would use this info inside of Excel for instance, except to get a list of my L4 library. To copy Bible verses into Excel seems like a lot of work to use the api. Figure you already have ideas on what you are trying to do with the api inside your Office apps. So i would be curious how you see using this.
I would try to Create the Launcher with late binding first (I did not test this, just wrote it here): Sub Test() Dim oLauncher 'DO NOT USE As LogosLauncher HERE on error goto ErrHandler Set oLauncher = CreateObject("LogosBibleSoftware.Launcher") 'The version independent ProgID oLauncher.LaunchApplication Beep 'If we get here it works" stop Exit Sub ErrHandler: Beep: Beep stop Debug.Print Err.Number & " - " & Err.Description End Sub If this worked, search if there is another LogosCom.exe file on your system. Hope this directs you into a meaningfull debug session.
Thanks for the help. The code seemingly completes correctly Set oLauncher = CreateObject("LogosBibleSoftware.Launcher"). But then, on oLauncher.LaunchApplication it errors out.
The Debug.Print returns:
-2147417851 - Automation errorThe server threw an exception.
This happens regardless if Verbum is open or not. Any ideas? When i copied Pieter's code (a few posts above), i had to: Setup a Reference to Logos' API (click an image below to view full size) Had to name the Class to what Pieter had named his Class Here is my Excel file with Pieter's stuff (class renamed) 3443.Book1.zip(had to zip the Excel file because the forum editor doesn't allow files with macros, so you will need to unzip the file. More steps When you open the Excel file, it will give you a warning that it contains Macros, so click on the gold bar & allow it to run the macros. Another thought, i would try opening Verbum before running the macro (see you already tried this) On the worksheet you will see a single button, click it once to start Pieter's macro.
Thanks for the help. Here is my Reference window. Everything seems to be correct as far as I can tell:
When I click on the button in your Excel Sheet I get the following pop-up:
The code then runs to the "Stop". I then run through the code with F8 line by line.
Debug.Print outputs "-- Created -- Logos class"
The code moves on to the Create subroutine. Then, on the line of code "Launcher.LaunchApplication CommandLineArguments" it errors out. Here is the message:
Maybe someone from Logos could run a test on a Verbum system to confirm if it is a Verbum bug?
Sounds like you have done everything right...
you might try using F5 instead (which will run to the next breakpoint), perhaps the stepping line by line is interrupting something timing-wise (just a guess).
EDIT:
i added a few extra Debug.Print statements (like this) to help me recognize when things were being added to the debug window (some steps added a lot of stuff).
Errors out at the same moment, although the error box is slightly more detailed (same error number, though):
This does sound like a Verbum issue.
But to cover all basis, below are images of how i have Excel Options set (File->Options)[click images for full-size viewing]
A long time ago, i had to fiddle with the Macros permission; i may have fiddled with a few other permissions too. So the above settings are what i have now.
This does sound like a Verbum issue. But to cover all basis, below are images of how i have Excel Options set (File->Options)
But to cover all basis, below are images of how i have Excel Options set (File->Options)
I set my options as yours, and the error is the same.
Maybe Bradley Grainger will see this post and check into this issue using Verbum. Sounds like you have tried everything.
P.S. He is the Logos person who added all the LogosAPI stuff to the Logos wiki page.
Just a thought, I wonder if your Excel, Office Library, .NET Framework versions, and if there is anything else being used, are the same...
Try to Run your document as administrator. Maybe there's a mixup in privilages? I don't think Verbum is the issue because if I understand it correctly it uses the same Engine as the other packages.
i am running L4 ver 4.5c SR-5, which uses .NET ver 3.5 (if i remember correctly).
Pieter mentioned earlier in this post that he is using L5 ver 5.2a SR-1, which uses .NET ver 4. Which would indicate that the LogosCom.exe works with both versions of .NET. Edit: (not necessarily true, windows can run both versions of .NET, but will require them to be installed separately)
Which brings to mind a possibly important point, Fr. Devin Roza are you running the 64-bit version of Office? my version is obviously a 32-bit version of Office (i am running 32-bit Vista OS). Edit: Pieter, are you running a 64-bit version of Office? Or are you running a 32-bit version of Office? (i don't know how Office deals with its code structure when communicating with api's when there is a significant difference between underlying assembly structures).
32 bit Office 2010 on 64 bit Windows 8.1 (which includes by default .NET 4.5).
I wonder if Verbum causes problems because the name of the Executable is different.
I use Verbum 5.2a SR-1. I use VBA quite a bit as well, and don't normally have any problem using API's within VBA. I'm pretty sure it is a Verbum related bug. Hopefully someone else can test with Verbum (ideally Bradley of course) and confirm if that is the case.
Office 2010 32bit on 64bit Win8
FYI
Here is an Excel file with macro to determine which OS & Office version it is (64 or 32 bit). It is zipped since it contains a macro.
7762.VersionButton.zip
Yes, that could be an issue. We'll investigate.
The best answer is always a Sample (3157.AnaliseLNData.zip provided as is, not well commented and not cleaned up [Logos 5.2a SR-2 (5.2.1.0098) | ComApi 3 | Office 2010 32bit | Win8 64bit]).
Input: ESV Louw-Nida data
Output: Summary of Louw-Nida Domains
Analysis: Without reading the passage the summary tells me that the passage contains valuable information about Relations, Attitudes and Emotions and maybe it's worth looking into Afformation and Negation etc... I would therefore spend more time on these domains when analising the passage in Greek.
Here is a Screenshot of a Filter and ChartType change of the Results in Excel:
LogosComApi:
Thoughts:
Maybe this is possible in Logos, I've tried it once by grouping some stuff in SearchResults.
What if I want to know how Israel traveled geographically in Genesis to Exodus. And then I want to compare the usage of all the terms they used to refer to the Creator. As a result I would be able to see if there is any relationship between the two. Did Israel prefer a certain usage in Egypt and another in other places? I did this once using the Export function in Logos. But a Macro could cut the time about 90%. I'm still investigating this idea.
I would like Word to scroll to References/Headwords etc. in the Active Document while in Logos or to Navigate Logos automatically while in Word. Using CompareTo and Intersect of the ComAPI would help doing this. Usefull for PBB.
Other ideas would be to automatically link FreeMind or FreePlane ideas as I work in those apps. Even linking Active Panels to ideas to leave a trail on my research and to have everything (Clippings|Notes|Passage Lists etc.) linked to a single map. It would be nice if I can drop a Panel in an app and it would create a link.
Most of all - This is fun and if I can improve my Sermon Prep while having fun, it's a win win situation.
The best answer is always a Sample (provided as is, not well commented and not cleaned up)
Pieter, thank you for sharing your example!
After spending a little time walking thru your macro i see there are much more possibilities than i had imagined or realized! i also see that your Box is much larger than my box (in relation to programming & depth of understanding the mechanisms for the ComApi 3). This will give me much to ponder and experiment with.
Thank you very much for sharing! It is amazing the gifts our Lord has blessed you with (i have not met a Pastor who has an understanding of programming before). i envy pastor's understanding of original languages of the Bible (but understand that is not a talent/gift/desire the Lord has given me). From your example i see a little how someone with your background and programming skills can make use of the ComApi.
May our Lord continue to bless you Sir!
your humble brother in Christ
This should be fixed in 5.2a SR-3. Please let us know if the script now works correctly with Verbum. [:)]
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.
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!!!
Yes, it now works perfectly. Thank you.
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.
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 ...
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:
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)
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:
because all other properties are read-only.
Test Results:
Code used to test:
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.
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 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
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.
PASTE INTO CDataBaseHelper:
PASTE INTO UserForm (and enter your Logos Path and your UserName as parameters)