home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "ScanSoft_OP12"
-
- ' Things to change for the next version of OP or for TextBridge:
- ' VB_Name, strActionAcquire, strActionSettings, strTagAcquire, strTagSettings
- ' strDotName
- ' MACRO_OMNIPAGE_OCR in OfficeAut.cpp
-
- ' Declare necessary API routines:
- Declare Function FindWindow Lib "user32" Alias _
- "FindWindowA" (ByVal lpClassName As String, _
- ByVal lpWindowName As Long) As Long
-
- Declare Function PostMessage Lib "user32" Alias _
- "PostMessageA" (ByVal hwnd As Long, ByVal msg As Long, _
- ByVal lParam As Long, ByVal wParam As Long) As Long
-
- Private lang As Integer
- Private strItemExit As String
- Private strItemAcquire As String
- Private strItemAcquireTip As String
- Private strItemSettings As String
- Private strItemSettingsTip As String
- 'This is the name of the macro function which calls the OCR function in OfficeAut
- Const strActionAcquire As String = "OmniPage12_OCR"
- 'This is the name of the macro function which calls the Settings function in OfficeAut
- Const strActionSettings As String = "OmniPage12_Settings"
- Const strTagAcquire As String = "OmniPage Pro 12 (Acquire)"
- Const strTagSettings As String = "OmniPage Pro 12 (Settings)"
- Private strTemplatePath As String
- Const strDotName As String = "\OP12_tmp.dot"
- Const SSFTAppName As String = "OmniPage Pro 12.0"
- Const SSFTWndName As String = "Scansoft.OCRAware12"
-
- 'This will send a 'start settings' message to the OpWare12.exe
- Sub OmniPage12_Settings()
-
- hwnd = FindWindow(SSFTWndName, 0)
-
- If hwnd <> 0 Then
- PostMessage hwnd, &H402, 0, 0 ' 402: WM_USER+2
- System.Cursor = wdCursorWait
- End If
-
- End Sub
-
- 'This will send a 'start OCR' message to the OpWare12.exe
- Sub OmniPage12_OCR()
-
- hwnd = FindWindow(SSFTWndName, 0)
-
- If hwnd <> 0 Then
- PostMessage hwnd, &H401, 0, 0 ' 401: WM_USER+1
- System.Cursor = wdCursorWait
- End If
-
- End Sub
-
- Private Sub SetupMenuItems()
-
- Dim newStr As String
- ' first find out what language this Word is in, then insert the appropriate menu items.
- Set myitem = CommandBars.Item("File")
- If myitem.NameLocal = "File" Then
- ' English and Italian both use "File" so we need to check Exit also
- Set exititem = CommandBars("File").Controls.Item("Exit")
- newStr = exititem.Caption
- If newStr = "E&xit" Then 'it's english
- ' English
- lang = 0
- strItemExit = "Exit"
- strItemAcquire = "Acquire Text (" + SSFTAppName + ")..."
- strItemAcquireTip = "Acquire Text (" + SSFTAppName + ")"
- strItemSettings = "Acquire Text Settings (" + SSFTAppName + ")..."
- strItemSettingsTip = "Acquire Text Settings (" + SSFTAppName + ")"
- Else
- ' Italian
- lang = 5
- strItemExit = "Esci"
- strItemAcquire = "Acquisisci testo (" + SSFTAppName + ")..."
- strItemAcquireTip = "Acquisisci testo (" + SSFTAppName + ")"
- strItemSettings = "Acquisisci impostazioni del testo (" + SSFTAppName + ")..."
- strItemSettingsTip = "Acquisisci impostazioni del testo (" + SSFTAppName + ")"
- End If
- ElseIf myitem.NameLocal = "Fichier" Then
- ' French
- lang = 1
- strItemExit = "Quitter"
- strItemAcquire = "AcquΘrir le texte (" + SSFTAppName + ")..."
- strItemAcquireTip = "AcquΘrir le texte (" + SSFTAppName + ")"
- strItemSettings = "Configuration d'acquisition du texte (" + SSFTAppName + ")..."
- strItemSettingsTip = "Configuration d'acquisition du texte (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Datei" Then
- ' German
- lang = 2
- strItemExit = "Beenden"
- strItemAcquire = "Texterfassen (" + SSFTAppName + ")..."
- strItemAcquireTip = "Texterfassen (" + SSFTAppName + ")"
- strItemSettings = "Texteinstellungen ⁿbernehmen (" + SSFTAppName + ")..."
- strItemSettingsTip = "Texteinstellungen ⁿbernehmen (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Archivo" Then
- ' Spanish
- lang = 4
- strItemExit = "Salir"
- strItemAcquire = "Adquirir texto (" + SSFTAppName + ")..."
- strItemAcquireTip = "Adquirir texto (" + SSFTAppName + ")"
- strItemSettings = "Parßmetros de Adquirir texto (" + SSFTAppName + ")..."
- strItemSettingsTip = "Parßmetros de Adquirir texto (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Bestand" Then
- ' Dutch
- lang = 6
- strItemExit = "Afsluiten"
- strItemAcquire = "Tekst verwerven (" + SSFTAppName + ")..."
- strItemAcquireTip = "Tekst verwerven (" + SSFTAppName + ")"
- strItemSettings = "Tekstinstellingen verwerven (" + SSFTAppName + ")..."
- strItemSettingsTip = "Tekstinstellingen verwerven (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Arkiv" Then
- ' Swedish
- lang = 8
- strItemExit = "Avsluta"
- strItemAcquire = "Generera text (" + SSFTAppName + ")..."
- strItemAcquireTip = "Generera text (" + SSFTAppName + ")"
- strItemSettings = "Generera textinstΣllningar (" + SSFTAppName + ")..."
- strItemSettingsTip = "Generera textinstΣllningar (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Arquivo" Or myitem.NameLocal = "Ficheiro" Then
- ' Brazilian
- lang = 15
- strItemExit = "Sair"
- strItemAcquire = "Adquirir texto (" + SSFTAppName + ")..."
- strItemAcquireTip = "Adquirir texto (" + SSFTAppName + ")"
- strItemSettings = "Adquirir definiτ⌡es de texto (" + SSFTAppName + ")..."
- strItemSettingsTip = "Adquirir definiτ⌡es de texto (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Fßjl" Then
- ' Hungarian
- lang = 16
- strItemExit = "KilΘpΘs"
- strItemAcquire = "Sz÷veg beolvasßsa (" + SSFTAppName + ")..."
- strItemAcquireTip = "Sz÷veg beolvasßsa (" + SSFTAppName + ")"
- strItemSettings = "Sz÷veg beolvasßs beßllφtßsai (" + SSFTAppName + ")..."
- strItemSettingsTip = "Sz÷veg beolvasßs beßllφtßsai (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Plik" Then
- ' Polish
- lang = 17
- strItemExit = "Zamknij"
- strItemAcquire = "Pobierz tekst (" + SSFTAppName + ")..."
- strItemAcquireTip = "Pobierz tekst (" + SSFTAppName + ")"
- strItemSettings = "Pobierz ustawienia tekstu (" + SSFTAppName + ")..."
- strItemSettingsTip = "Pobierz ustawienia tekstu (" + SSFTAppName + ")"
- ElseIf myitem.NameLocal = "Soubor" Then
- ' Czech
- lang = 18
- strItemExit = "Konec"
- strItemAcquire = "Zφskat text (" + SSFTAppName + ")..."
- strItemAcquireTip = "Zφskat text (" + SSFTAppName + ")"
- strItemSettings = "Nastavenφ funkce Zφskat text (" + SSFTAppName + ")..."
- strItemSettingsTip = "Nastavenφ funkce Zφskat text (" + SSFTAppName + ")"
- End If
-
- End Sub
-
- Public Sub AutoExec()
-
- strTemplatePath = Application.StartupPath + strDotName
-
- ' There will be an error if the Acquire Text item doesn't exist.
- ' But we still want to execute the next statement
- On Error Resume Next
-
- ' So that we don't save our changes into normal.dot. This code also needs to
- ' be in AutoExit - wherever we make changes to Word.
- CustomizationContext = Templates(strTemplatePath)
-
- SetupMenuItems
-
- Set oaitem = CommandBars("File").Controls.Item(strItemAcquire)
- If oaitem.Caption <> strItemAcquire Then
- itemindex = CommandBars("File").Controls.Item(strItemExit).Index
- Set newitem = CommandBars("File").Controls.Add(Type:=msoControlButton)
- With newitem
- .Move Before:=itemindex
- .Caption = strItemAcquire
- .TooltipText = strItemAcquireTip
- .Style = msoButtonCaption
- .Visible = True
- .BeginGroup = True
- .FaceId = 0
- .OnAction = strActionAcquire
- .Tag = strTagAcquire
- End With
- End If
-
- Set oaitem = CommandBars("File").Controls.Item(strItemSettings)
- If oaitem.Caption <> strItemSettings Then
- itemindex = CommandBars("File").Controls.Item(strItemAcquire).Index
- Set newitem = CommandBars("File").Controls.Add(Type:=msoControlButton)
- With newitem
- .Caption = strItemSettings
- .TooltipText = strItemSettingsTip
- .Style = msoButtonCaption
- .FaceId = 0
- .OnAction = strActionSettings
- .Tag = strTagSettings
- .Move Before:=itemindex + 1
- End With
- End If
-
- ecount = CommandBars("File").Controls.Count
- Set exititem = CommandBars("File").Controls.Item(ecount)
- exitIndex = exititem.Index
- With exititem
- .BeginGroup = True
- End With
-
- 'so that we don't get the "Do you want to save..." message
- Templates(aTemp).Saved = True
-
- End Sub
-
- Public Sub AutoExit()
-
- ' this will remove the ocraware global addin whenever Word is exited.
- ' When OmniPage is uninstalled, the Aware97.dot file is removed. However, when Word was
- ' run, the menu items continued to show, with no actions performed. Now, we will manually
- ' remove it from the AddIns list everytime we exit Word. And when Word is started the next
- ' time, if the Aware97.dot file is in the startup menu it will reload the AddIn.
-
- Dim newStr As String
- On Error Resume Next
-
- ' So that we don't save our changes into normal.dot. This code is also
- ' in AutoExex - wherever we make changes to Word.
- CustomizationContext = Templates(strTemplatePath)
-
- Set oaitem = CommandBars("File").Controls.Item(strItemAcquire)
- newStr = oaitem.TooltipText
- If newStr = strItemAcquireTip Then
- oaitem.Delete
- End If
-
- Set oaitem = CommandBars.Item("File").Controls.Item(strItemSettings)
- newStr = oaitem.TooltipText
- If newStr = strItemSettingsTip Then
- oaitem.Delete
- End If
-
- NormalTemplate.Saved = True
- Templates(aTemp).Saved = True
-
- End Sub
-