Difference between revisions of "Bibliographic/Hints and Tips/Import Macros"
From Apache OpenOffice Wiki
m |
m (→Introduction) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Introduction== | ==Introduction== | ||
− | Add these | + | Add these AOO Basic macro. Using |
− | Tools | + | {{menu|Tools|Macros|Organize Macros|OpenOffice Basic…}} |
The macros calls the file picker dialog and uses the selected *.ris or *.bib file as input to the import_ris or import_bib batch scripts. The import_bib script uses [[Bibliographic_Software_and_Standards_Information#Bibutils |bibutiles]] programs to convert BibTeX to xml to RIS. | The macros calls the file picker dialog and uses the selected *.ris or *.bib file as input to the import_ris or import_bib batch scripts. The import_bib script uses [[Bibliographic_Software_and_Standards_Information#Bibutils |bibutiles]] programs to convert BibTeX to xml to RIS. | ||
== Import RIS bibliographic data == | == Import RIS bibliographic data == | ||
− | + | <syntaxhighlight lang="oobas"> | |
Sub ImportRIS | Sub ImportRIS | ||
Dim oFilePicker As Object, oSimpleFileAccess As Object | Dim oFilePicker As Object, oSimpleFileAccess As Object | ||
Line 36: | Line 36: | ||
End If | End If | ||
End Sub | End Sub | ||
− | + | </syntaxhighlight> | |
Note: You may need to add the full path to the import-ris script file in the Shell command, if it produces a can not find error message. | Note: You may need to add the full path to the import-ris script file in the Shell command, if it produces a can not find error message. | ||
== Import BibTeX bibliographic data == | == Import BibTeX bibliographic data == | ||
− | + | <syntaxhighlight lang="oobas"> | |
Sub ImportBibTeX | Sub ImportBibTeX | ||
Dim oFilePicker As Object, oSimpleFileAccess As Object | Dim oFilePicker As Object, oSimpleFileAccess As Object | ||
Line 73: | Line 73: | ||
End If | End If | ||
End Sub | End Sub | ||
− | + | </syntaxhighlight> | |
===Improvements needed=== | ===Improvements needed=== | ||
Line 80: | Line 80: | ||
==Add to Menu== | ==Add to Menu== | ||
− | + | Once you have saved these macros you can assign it to a new menu item or hot-key in the {{menu|Tools|Customize}} options. | |
[[User:Dnw|David Wilson]] | [[User:Dnw|David Wilson]] | ||
− | [[Category:Bibliographic]] | + | [[Category:Bibliographic|Hints]] |
+ | [[Category:Hints|Bibliographic/Hints]] | ||
+ | [[Category:Macros|Bibliographic/Macros]] |
Latest revision as of 15:19, 29 September 2021
Contents
Introduction
Add these AOO Basic macro. Using
Tools → Macros → Organize Macros → OpenOffice Basic…
The macros calls the file picker dialog and uses the selected *.ris or *.bib file as input to the import_ris or import_bib batch scripts. The import_bib script uses bibutiles programs to convert BibTeX to xml to RIS.
Import RIS bibliographic data
Sub ImportRIS Dim oFilePicker As Object, oSimpleFileAccess As Object Dim oSettings As Object, oPathSettings As Object Dim oTextField As Object, oTextFieldModel As Object Dim sFileURL As String Dim sFiles As Variant REM file dialog oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" ) REM set filter oFilePicker.AppendFilter( "ris files (*.ris)", "*.ris" ) oFilePicker.AppendFilter( "All files (*.*)", "*.*" ) oFilePicker.SetCurrentFilter( "ris files (*.ris)", "*.ris" ) REM if no file URL is set, get path settings from configuration REM set display directory oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then oFilePicker.setDisplayDirectory( sFileURL ) End If REM execute file dialog If oFilePicker.execute() Then sFiles = oFilePicker.getFiles() sFileURL = sFiles(0) rem print sFileURL Shell("import-ris",1,sel) End If End Sub
Note: You may need to add the full path to the import-ris script file in the Shell command, if it produces a can not find error message.
Import BibTeX bibliographic data
Sub ImportBibTeX Dim oFilePicker As Object, oSimpleFileAccess As Object Dim oSettings As Object, oPathSettings As Object Dim oTextField As Object, oTextFieldModel As Object Dim sFileURL As String Dim sFiles As Variant REM file dialog oFilePicker = CreateUnoService( "com.sun.star.ui.dialogs.FilePicker" ) REM set filter oFilePicker.AppendFilter( "BibTeX files (*.bib)", "*.bib" ) oFilePicker.AppendFilter( "All files (*.*)", "*.*" ) oFilePicker.SetCurrentFilter( "BibTeX files (*.bib)", "*.bib" ) REM if no file URL is set, get path settings from configuration REM set display directory oSimpleFileAccess = CreateUnoService( "com.sun.star.ucb.SimpleFileAccess" ) If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then oFilePicker.setDisplayDirectory( sFileURL ) End If REM execute file dialog If oFilePicker.execute() Then sFiles = oFilePicker.getFiles() sFileURL = sFiles(0) rem print sFileURL Shell("/opt/openoffice.org2.0/program/import_bib",1,sel) End If End Sub
Improvements needed
It would be good if the macros collected the sysout from the utility programs and displayed them to the user so that she may see any error messages.
Add to Menu
Once you have saved these macros you can assign it to a new menu item or hot-key in the Tools → Customize options. David Wilson