PrecisionCalc
inspector
text
Do Anything with Text in Formulas

 

Using inspector text In Your Programming Code
Visual Basic Projects, Excel VBA Macros, Access VBA Macros, Etc.
 

 

You can use inspector text in your programming code, such as Visual Basic projects, Excel VBA macros, Access VBA macros, Word VBA macros, any other application's VBA macros, or from any other code that can call a COM (ActiveX, OLE) server.

As a developer, you can freely distribute the free edition of inspector text to your users. However, if you want to distribute a paid edition of inspector text to your users, you must buy a distribution license to do so.

 

Here's an example:

   Dim Oit As Object
   Dim strRet as String
   Set Oit = CreateObject("Inspector_Text.clsInspectorText")
   strRet = Oit.itSEARCH("abc", "b")
   Debug.Print strRet
   Set Oit = Nothing


Alternatively, if you prefer Early Binding, you could set a reference (in Excel's VBE, choose Tools | References) to inspector text, and do this:

   Dim Oit As Inspector_Text.clsInspectorText
   Dim strRet as String
   Set Oit = CreateObject("Inspector_Text.clsInspectorText")
   strRet = Oit.itSEARCH("abc", "b")
   Debug.Print strRet
   Set Oit = Nothing


Note that Early Binding probably won't be a major advantage with the kind of work inspector text does, and it may require removing and recreating the reference when new versions of inspector text are installed in the future.

 

This example enters the result in a Word document and saves it as plain text:

   Dim Oit As Object, oWord As Object, oDoc As Object
   Dim strRet As String, strSavePath As String
   Const WORD_FILE_FORMAT_PLAIN_TEXT As Long = 2

   Set Oit = CreateObject("Inspector_Text.clsInspectorText")
   Set oWord = CreateObject("Word.Application")
   oWord.Visible = True 'optional, if you want to see it.
   strRet = Oit.itSEARCH("abc", "b")
   Set oDoc = oWord.Documents.Add
   oWord.Selection.TypeText strRet

   strSavePath = Application.GetSaveAsFilename( _
                      "inspector text result.txt", _
                      "Text Files (*.txt), *.txt", , "Save As")
   If strSavePath <> "False" Then
        oDoc.SaveAs strSavePath, WORD_FILE_FORMAT_PLAIN_TEXT
        MsgBox "Saved as " & strSavePath & ".", _
                vbInformation + vbOKOnly, "inspector text Result Saved"
   Else
        MsgBox "inspector text result not saved.", _
                vbCritical + vbOKOnly, "Not Saved"
   End If

   oDoc.Close False
   oWord.Quit
   Set oDoc = Nothing
   Set oWord = Nothing
   Set Oit = Nothing

 

In future versions I may need to have inspector text detect what client is using it and restrict random clients' usage, requiring their developers to license it. But I'll be sure to allow Excel's VBA to use it without restriction. Any future restriction would apply only to other random EXEs trying to use inspector text , not to Excel VBA.
 

 

PrecisionCalc Home Page