The following are three Word Basic macros that can be used to call CC.dll from Microsoft Word. Function DoCC can be copied and become part of your own macro code. LibCC16 and LibCC32 should be saved as separate macros in your template. The function DoCC will call either LibCC16.ConsistentChange or LibCC32.ConsistentChange, depending on if it is running in Word 6 or Word 7. ============================================================ Function DoCC(FNameIn$, FNameTable$, FNameOut$) ' runs Consistent Changes on a text file ' returns 0 if all okay, or an error number if there were problems 'Check Environment and Version of Word and call 16 or 32 bit CC nCall = 0 ver$ = AppInfo$(2) 'version of Word If InStr(ver$, "2.0") Then Stop 'this macro not designed for WW2 If InStr(ver$, "6.0") Then nCall = 16 'Word 6.0 is a 16-bit app (except 6.0 for NT?) 'ElseIf InStr(ver$, "8.0") Then ' nCall = 33 'LibCC32 doesn't work under Word 8.0 for some reason. Else nCall = 32 'Later versions of Word are 32-bit EndIf REM env$ = AppInfo$(1) 'environment REM If InStr(env$, "Windows 3.1") Then nCall = 2'temporary override Select Case nCall REM Case 2 REM iRtn = LibCCDOS.ConsistentChange(FNameIn$, FNameTable$, FNameOut$) Case 16 iRtn = LibCC16.ConsistentChange(FNameIn$, FNameTable$, FNameOut$) Case 32 iRtn = LibCC32.ConsistentChange(FNameIn$, FNameTable$, FNameOut$) 'Case 33 'iRtn = LibCC32DOS.ConsistentChange(FNameIn$, FNameTable$, FNameOut$) Case Else iRtn = 9 : Stop End Select 'Check for no output If iRtn = 0 And Files$(FNameOut$) = "" Then MsgBox("Error- CC did not produce its output file: " + FNameOut$, g_sTitle$, 16) iRtn = 9999 EndIf If iRtn = 0 Then Open FNameOut$ For Input As #1 nBytes = Lof(#1) Close #1 If nBytes <= 1 Then MsgBox("Error- CC produced empty output file: " + FNameOut$, g_sTitle$, 16) iRtn = 9998 EndIf EndIf DoCC = iRtn End Function ============================================================ 'LibCC16 'Library function to call CC from 16-bit WordBasic. ' Bryan Wussow and Doug Rintoul Oct96 'Mar97 fixed hTable overflow 'Prototype: ' n = ConsistentChange(sInputFile$, sCCTable$, sOutputFile$) 'Return value: 0 if successful, nonzero if error 'Prerequisite: CC.DLL should be in the Windows\System directory Declare Function CCLoadTable Lib "CC.DLL"(FNtable$, phTable As String, hInstance As Integer) As Integer Declare Function CCUnloadTable Lib "CC.DLL"(hTable As Integer) As Integer Declare Function CCProcessFile Lib "CC.DLL"(hTable As Integer, FNInput$, FNoutput$, bAppend As Integer) As Integer Declare Function GetActiveWindow Lib "User"() As Integer Declare Function GetWindowWord Lib "User"(hWnd As Integer, offset As Integer) As Integer Function ConsistentChange(sInputFile$, sCCTable$, sOutputFile$) hWnd = GetActiveWindow hInstance = GetWindowWord(hWnd, - 6) x$ = " " '4-byte string used to mimic ptr to HANDLE var iStatus = 0 'init function status val 'Load the CC table iRtn = CCLoadTable(sCCTable$, x$, hInstance) If iRtn <> 0 Then iStatus = 1 'CCLoadTable problem If (iStatus = 0) Then ' Convert the string to a handle Multiplier = 1 hTable = 0 nBytes = Len(x$) If nBytes > 2 Then nBytes = 2 For i = 1 To nBytes hTable = hTable + Asc(Mid$(x$, i, 1)) * Multiplier Multiplier = Multiplier * 256 Next i 'hTable may be larger than 32K & cause overflow If hTable > 32767 Then hTable = hTable - 65536 End If REM On Error Resume Next 'ignore overflow? 'Do the changes iRtn = CCProcessFile(hTable, sInputFile$, sOutputFile$, 0) If (iRtn <> 0) Then iStatus = 2 ' Clean up iRtn = CCUnloadTable(hTable) If (iRtn <> 0 And iStatus = 0) Then iStatus = 3 EndIf 'Error Notification REM bErrNotify = 0 ' disable because cc.dll itself notifies the user REM DlgTitle$ = "LibCC16" REM If bErrNotify And iStatus = 1 Then REM MsgBox("Error 1 occurred with CC. Check that "+ sCCTable$ + " exists.", DlgTitle$, 48) REM EndIf REM If bErrNotify And iStatus = 2 Then REM MsgBox("Error 2 occurred with CC. Check that " + sInputFile$ + " exists.", DlgTitle$, 48) REM EndIf REM If bErrNotify And iStatus = 3 Then REM MsgBox("Error 3 occurred with CC.", DlgTitle$, 48) REM EndIf 'Return ConsistentChange = iStatus 'return status (0 is success) End Function 'test program Sub Main in$ = "c:\temp\test.txt" tbl$ = "c:\temp\test.cct" out$ = "c:\temp\testout.txt" Kill out$ i = ConsistentChange(in$, tbl$, out$) If i = 0 Then FileOpen .Name = out$ End Sub ============================================================ 'LibCC32 'Library function to call CC from 32-bit WordBasic. ' Bryan Wussow and Doug Rintoul Oct96 ' Patched with cc32wrap.dll, then restored Sept 97 'Prototype: ' n = ConsistentChange(sInputFile$, sCCTable$, sOutputFile$) 'Return value: 0 if successful, nonzero if error 'Prerequisite: CC32.DLL should be in the Windows\System directory Declare Function CCLoadTable Lib "CC32.DLL"(FNtable$, phTable As String, hInstance As Long) As Long Declare Function CCUnloadTable Lib "CC32.DLL"(hTable As Long) As Long Declare Function CCProcessFile Lib "CC32.DLL"(hTable As Long, FNinput$, FNoutput$, bAppend As Long) As Long Declare Function GetActiveWindow Lib "User32"() As Long Declare Function GetWindowLongA Lib "User32"(hWnd As Long, offset As Long) As Long Function ConsistentChange(sInputFile$, sCCTable$, sOutputFile$) hWnd = GetActiveWindow hInstance = GetWindowLongA(hWnd, - 6) hInstance = 0 'per Brian Yoder, this should be sufficient x$ = " " '4-byte string used to mimic ptr to HANDLE var iStatus = 0 'init function status val 'Load the CC table iRtn = CCLoadTable(sCCTable$, x$, hInstance) If iRtn <> 0 Then iStatus = 1 'CCLoadTable problem If (iStatus = 0) Then ' Convert the string to a handle Multiplier = 1 hTable = 0 nBytes = Len(x$) If nBytes > 4 Then nBytes = 4 For i = 1 To nBytes hTable = hTable + Asc(Mid$(x$, i, 1)) * Multiplier REM if asc(mid$(x$,i,1) then \ REM hTable = hTable + Asc(Mid$(x$, i, 1)) * Multiplier Multiplier = Multiplier * 256 Next i 'Do the changes iRtn = CCProcessFile(hTable, sInputFile$, sOutputFile$, 0) If (iRtn <> 0) Then iStatus = 2 ' Clean up iRtn = CCUnloadTable(hTable) If (iRtn <> 0 And iStatus = 0) Then iStatus = 3 EndIf 'Error Notification REM bErrNotify = 0 ' disable because cc.dll itself notifies the user REM DlgTitle$ = "LibCC32" REM If bErrNotify And iStatus = 1 Then REM MsgBox("Error 1 occurred with CC. Check that "+ sCCTable$ + " exists.", DlgTitle$, 48) REM EndIf REM If bErrNotify And iStatus = 2 Then REM MsgBox("Error 2 occurred with CC. Check that " + sInputFile$ + " exists.", DlgTitle$, 48) REM EndIf REM If bErrNotify And iStatus = 3 Then REM MsgBox("Error 3 occurred with CC.", DlgTitle$, 48) REM EndIf 'Return ConsistentChange = iStatus 'return status (0 is success) End Function 'test program Sub Main in$ = "c:\temp\test.txt" tbl$ = "c:\temp\test.cct" out$ = "c:\temp\testout.txt" Kill out$ i = ConsistentChange(in$, tbl$, out$) If i = 0 Then FileOpen .Name = out$ End Sub