chkesp.c Office11 Visual Studio 6.0 C++

L

lawsce

We were using the Find.Execute function to locate text in a Word document
with Office 2000. We imported the Office10 files mso.dll and msword10.olb.
Now we have Office 2003 and we get the chkesp.c error that our declarations
do not match. Can anyone help?

Here are our imports:
#import "C:\Program Files\Common Files\Microsoft Shared\Office11\mso.dll"
#import "c:\program files\common files\microsoft shared\vba\vba6\vbe6ext.olb"
#import "C:\Program Files\Microsoft Office\Office11\msword.olb"
rename("ExitWindows", "WordExitWindows")

Here is the code snipet:
void AddErrorInfo(Word::_ApplicationPtr pWord, CString strFilename, CString
strOut)
{
int i, Pos;
CFileException fe;
CStdioFile InFile, Temp, TempFile, OutFile;
CString strSeventhChar, strInPath, strTemp, strTempPath,
strOutPath, strTP, strErr, strErrInfo, strFile;
Word::SelectionPtr pSel;

COleVariant covTrue((short)1,VT_I2),
covFalse((short)0,VT_I2),
covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR),
covFindContinue((short)1,VT_I2);

// Build input path
strInPath.Format("%s\\%s", strOut, strFilename);

// Build output path
strOutPath = strInPath.Left(strInPath.GetLength()-1);

// Open the *.CBP file and get a filename
if(InFile.Open(strInPath, CFile::modeRead | CFile::shareDenyNone, &fe))
{
Doc("\tInput file %s was opened", strInPath);

// Open the requested output file to write (*.CB)
if(OutFile.Open(strOutPath, CFile::modeWrite | CFile::modeCreate |
CFile::shareDenyNone, &fe))
{
Doc("\tOutput file %s was opened", strOutPath);
}

// Get a filename from the *.CBP file
while(InFile.ReadString(strFile))
{
Chk4Esc(); // include this inside any loop

// if a blank line is in the file, get another line
if(strFile.IsEmpty())
{
continue;
}

// Save the 7th character of the test filename for later use.
strSeventhChar = strFile.GetAt(6); // 0 based

// Build temporary path for file to open (*.AWL or *.S)
strTempPath.Format("%s\\%s", strOut, strFile);

// Open the requested file to get the testname from
if(TempFile.Open(strTempPath, CFile::modeRead |
CFile::shareDenyNone, &fe))
{
// Search for "Test Name:" in the file
while(TempFile.ReadString(strTemp))
{
Chk4Esc(); // include this inside any loop

// find this
Pos = strTemp.Find("Test Name:");

if(Pos > -1) // Test Name: was found
{
//throw away "Test Name:" characters
//keep rest of the string
strTemp = strTemp.Mid(Pos+10);

//chops off any spaces or tabs from the left of filename
strTemp.TrimLeft();

//
***********************************************************
// Get rid of file extension before doing search because
WORD
// will not do a "Find Whole Word" search if any punctuation
// is present.
//
***********************************************************

// check for a filename extension
Pos = strTemp.Find(".");

if(Pos > -1) // extension was found
{
// keep filename only, no extension
strTemp = strTemp.Left(Pos);
}

break;
}
strTemp.Empty();
}
// close temp file
TempFile.Close();
}


// get the document contents into a selection pointer
pSel = pWord->GetSelection();
if(pSel != NULL)
{
// now, find the desired text in the selection
pSel->Find->Execute(COleVariant(strTemp,VT_BSTR),
covTrue, // MatchCase
covTrue, // MatchWholeWord
covFalse, // MatchWildCards
covFalse, // MatchSoundsLike
covFalse, // MatchAllWordForms
covTrue, // Forward
covFindContinue, // Wrap
covOptional, // Format
covOptional, // ReplaceWith
covOptional // Replace
);

We die right at pSel->Find->Execute.
 
L

lawsce

Turns out that Excel 5 is messing up the GUIDS for the Word automation. The
simple, temporary fix is to reregister msword.olb using regtlib. The
permanent fix is to recode using late binding.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top