I'm a big fan of Babylon to easily translate or explain something. I also use it a lot with my own created "dictionaries". For example: I made some script to easily export all my Microsoft Outlook contacts and create a Babylon dictionary out of it. Whenever I need a name, email, phone number, ... of some contact, I just have to provide a name, company, phone number,... to immediately popup my contacts details with just a click.
Follow these steps if you want to be able to export your own Outlook contacts to Babylon.
- Export MS Outlook contacts to Excel file: Menu 'File' -> 'Import and export' -> 'Export to file' -> 'Microsoft Excel 97-2003' -> 'Contacts' -> chose some location to save the file
- Open the generated Excel file
- Add a new macro in the Excel file: Menu 'Developer' -> 'Visual Basic' -> Sheet1 -> Copy-paste my macro from here :
- Close Visual Basic editor
- Run the created Macro: Menu 'Developer' -> 'Macro' –> 'ConvertOutlookContactsToBabylon'
- A file called 'c:\Contacts.gls' will be created on your C: drive
- Open BabylonBuilder.exe and open the gls file 'c:\Contacts.gls': Menu 'File' -> 'Open' (The new version of BabylonBuilder can also be used to compile .gls to .bgl)
- Press 'Edit screen'
- Press 'Build screen'
- Press 'Build'
- A file called 'Contacts.bgl' file will be created, this is the compile Babylon dictionary.
- Double click the 'Contacts.bgl' file to load it into Babylon
- Use Babylon to search on any contact and immediately see all contact details.
Private Declare Function GetDesktopWindow Lib "user32" () As LongPrivate Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As LongPrivate Type OPENFILENAMElStructSize As LonghwndOwner As LonghInstance As LonglpstrFilter As StringlpstrCustomFilter As StringnMaxCustFilter As LongnFilterIndex As LonglpstrFile As StringnMaxFile As LonglpstrFileTitle As StringnMaxFileTitle As LonglpstrInitialDir As StringlpstrTitle As Stringflags As LongnFileOffset As IntegernFileExtension As IntegerlpstrDefExt As StringlCustData As LonglpfnHook As LonglpTemplateName As StringEnd TypeSub ConvertOutlookContactsToBabylon()sFile = "C:\Contacts.gls"Application.ScreenUpdating = False' turns off screen updatingApplication.DisplayStatusBar = True' makes sure that the statusbar is visibleApplication.StatusBar = "Preparing babylon file in " + sFile'--------------------------------------------------------------------------'Create export file'--------------------------------------------------------------------------Set fs = CreateObject("Scripting.FileSystemObject")Set f = fs.CreateTextFile(sFile, True)f.writeline ("### Glossary title:Contacts")f.writeline ("### Author:")f.writeline ("### Description:Contacts")f.writeline ("### Source language:Dutch")f.writeline ("### Source alphabet:Latin")f.writeline ("### Target language:Dutch")f.writeline ("### Target alphabet:Latin")f.writeline ("### Icon:")f.writeline ("### Icon2:")f.writeline ("### Browsing enabled?Yes")f.writeline ("### Type of glossary:00000000")f.writeline ("### Case sensitive words?0")f.writeline ("; DO NOT EDIT THE NEXT **SIX** LINES - Babylon-Builder generated text !!!!!!")f.writeline ("### Glossary id:029f645f6877899f836e9c869d8a89447c6e8e9e8271769a9d659559957889978372869c8477772a9693897f5d89526e7c458944648127444854575a428a9244977c946e5b524147584c559fcc23264eac62515a414f4b8b279a224f5a42474f5f555638993bd86e5b524147584c559f908e2d60475e5a4b597e66833a32294d48429a4d5955")f.writeline ("### Confirmation string:7C221QRF")f.writeline ("### File build number:01292D7C")f.writeline ("### Build:")f.writeline ("### Glossary settings:00000000")f.writeline ("### Gls type:00000001")f.writeline ("; DO NOT EDIT THE PREVIOUS **SIX** LINES - Babylon-Builder generated text !!!!!!")f.writeline ("### Part of speech table:")f.writeline ("### Private label id:")f.writeline ("### Min version:0")f.writeline ("### Regular expression:")f.writeline ("### Glossary section:")'Find a free column to fill with copy' and find the column to copy fromFor iColumn = 1 To 65000'Empty column, stop loopcolName = CStr(Worksheets(1).Cells(1, iColumn).Value)If colName = Empty ThenlastColumn = iColumnExit ForEnd If'Columns to removeIf colName = "E-mail Type" Or colName = "E-mail Display Name" Or colName = "E-mail 2 Type" Or colName = "E-mail 2 Type" Or colName = "E-mail 2 Display Name" Or colName = "E-mail 3 Type" Or colName = "E-mail 3 Display Name" Or colName = "Gender" Or colName = "Priority" Or colName = "Private" Or colName = "Sensitivity" ThenWorksheets(1).Columns(iColumn).Delete (xlShiftToLeft)iColumn = iColumn - 1End IfNext iColumn'go thru all rowsFor iRow = 2 To 65000'check if last row to doIf Worksheets(1).Cells(iRow, 2).Value = Empty And Worksheets(1).Cells(iRow, 4).Value = Empty And Worksheets(1).Cells(iRow + 1, 2).Value = Empty And Worksheets(1).Cells(iRow + 1, 4).Value = Empty ThenExit ForEnd If'start new line for babylon display dataWorksheets(1).Rows(iRow + 1).Insert (xlShiftDown)'insert empty row between each contactWorksheets(1).Rows(iRow + 2).Insert (xlShiftDown)'output line, will be written to filesLine = ""'babylon subjectsSubject = ""FullName = CStr(Worksheets(1).Cells(iRow, 2).Value) + " " + CStr(Worksheets(1).Cells(iRow, 4).Value) + "|" + CStr(Worksheets(1).Cells(iRow, 4).Value) + " " + CStr(Worksheets(1).Cells(iRow, 2).Value) + "|"'keep track of column working in, since cells will be deleted but not in header rowiColumn = 1For headerColumn = 1 To (lastColumn - 1)If Worksheets(1).Cells(iRow, iColumn).Value <> Empty Then'convert value to stringelementValue = CStr(Worksheets(1).Cells(iRow, iColumn).Value)'eleminiate empty birthday datesIf elementValue = "0/0/00" ThenWorksheets(1).Cells(iRow, iColumn).Value = ""Else'insert babylon display datadisplayData = elementValue'convert email addresses to linksIf InStr(displayData, "@") And (Not InStr(displayData, " ")) ThendisplayData = "<a href='mailto:" + elementValue + "'>" + elementValue + "</a>"End If'convert web linksIf Worksheets(1).Cells(1, headerColumn).Value = "WebPage" ThenIf Not InStr(elementValue, "http://") ThendisplayData = "<a href='http://" + elementValue + "'>" + elementValue + "</a>"ElsedisplayData = "<a href='" + elementValue + "'>" + elementValue + "</a>"End IfEnd If'convert phone numbersIf InStr(Worksheets(1).Cells(1, headerColumn).Value, "Phone") Or InStr(Worksheets(1).Cells(1, headerColumn).Value, "Fax") ThendisplayData = Replace(Replace(Replace(elementValue, "+31", "+31."), "+33", "+33."), "+32", "+32.")End If'convert categoriesIf Worksheets(1).Cells(1, headerColumn).Value = "Categories" ThendisplayArray = Split(displayData, ";")displayData = ""For Each sArrayElement In displayArraydisplayData = displayData + "<a href='bword://" + sArrayElement + "'>" + sArrayElement + "</a> "NextEnd If'Put display data in sheetWorksheets(1).Cells(iRow + 1, 1).Value = Worksheets(1).Cells(iRow + 1, 1).Value + "<b>" + Worksheets(1).Cells(1, headerColumn).Value + "</b>: " + Replace(Replace(Replace(displayData, vbCrLf, "<br>"), vbCr, "<br>"), ";", ",") + "<br>"'replace vbCrLf vbCr ; with |elementValue = Replace(Replace(Replace(Replace(elementValue, vbCrLf, "|"), vbCr, "|"), ";", "|"), "||", "|")'replace all special character for babylon search datareplacedChars = Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(elementValue, " ", "|"), ".", "|"), "@", "|"), ":", "|"), ";", "|"), "-", "|"), "/", "|"), "||", "|"), "||", "|"), "|&|", "|"), "|-|", "|"), "|.|", "|"), "|~|", "|"), "|=|", "|")replacedChars = Replace(Replace(Replace(replacedChars, "+31", "0"), "+33", "0"), "+32", "0")If replacedChars <> elementValue ThenWorksheets(1).Cells(iRow, iColumn).Value = elementValue + "|" + replacedChars + "|"ElseWorksheets(1).Cells(iRow, iColumn).Value = elementValue + "|"End IfIf headerColumn = 1 Or headerColumn = 2 Or headerColumn = 3 Or headerColumn = 4 ThenIf sSubject = "" ThensSubject = elementValueElsesSubject = sSubject + " " + elementValueEnd IfEnd IfEnd IfIf Worksheets(1).Cells(1, headerColumn).Value <> "Notes" ThensLine = sLine + Worksheets(1).Cells(iRow, iColumn).ValueEnd If'handle next cell in next loop of ForiColumn = iColumn + 1Else'empty column: remove cell and shift other cells left'keep track of original cell location to get the heading name of the cell'deleting cells is very slow!'Worksheets(1).Cells(iRow, iColumn).Delete (xlShiftToLeft)'handle next cell in next loop of For, not needed if cells are deletediColumn = iColumn + 1End IfNext headerColumnsSubject = Replace(sSubject, "|", " ")'writing to filef.writeline (Replace(sSubject + "|" + FullName + sLine, "||", "|"))f.writeline (Replace(CStr(Worksheets(1).Cells(iRow + 1, 1).Value), vbTab, " "))f.writeline ("")iRow = iRow + 2Next iRow'Close export filef.CloseApplication.ScreenUpdating = True' turns off screen updatingApplication.DisplayStatusBar = True' makes sure that the statusbar is visibleMsgBox "Babylon file prepared in " + sFileEnd Sub
No comments:
Post a Comment