Example 6 - Automate PASSOLO from Visual Basic
This example demonstrates how you can automate Passolo from another application. A Visual Basic application is used to create a temporary project with notepad.exe as a source file. A sheet in Excel will be opened and all source strings will be copied to the Excel sheet. Passolo will be closed and the temporary project will be deleted.
0001 Private Sub Command1_Click()
0002 Dim psl As PassoloApp
0003 Dim pslprj As PslProject
0004 Dim srclst As PslSourceList
0005
0006 Set psl = CreateObject("PASSOLO.Application")
0007 Set pslprj = psl.Projects.Add("Scratch", "c:\temp\scratch")
0008 Set srclst = pslprj.SourceLists.Add("c:\winnt\system32\notepad.exe", "Notepad")
0009 srclst.Update
0010
0011 Dim x As Excel.Application
0012 Dim wb As Excel.Workbook
0013 Dim ws As Excel.Worksheet
0014 Set x = New Excel.Application
0015 Set wb = x.Workbooks.Add()
0016 Set ws = x.ActiveSheet
0017
0018 Dim i As Long
0019 For i = 1 To srclst.StringCount
0020 ws.Range("a" & CStr(i)).Select
0021 x.ActiveCell.FormulaR1C1 = srclst.String(i).Text
0022 Next i
0023 x.Visible = True
0024
0025 psl.Quit
0026 Dim fs As FileSystemObject
0027 Set fs = CreateObject("Scripting.FileSystemObject")
0028 fs.DeleteFile ("c:\temp\scratch\scratch.tok\logfile.txt")
0029 fs.DeleteFile ("c:\temp\scratch\scratch.tok\notepad.bin")
0030 fs.DeleteFile ("c:\temp\scratch\scratch.lpj")
0031 fs.DeleteFolder ("c:\temp\scratch\scratch.tok")
0032 fs.DeleteFolder ("c:\temp\scratch")
0033 End Sub